asp.net-mvc

ASP.NET MVC default path

I am trying to figure out how to route my application to a default controller/task/id when none is specified in a request. Here is my one routing instruction... routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "LML", action = "TaskLibrary", ...

Define a seperate ViewModel for EditProfile View or use the User model (DRY vs convenience)

For my Edit Profile page, all the items are from the User entity. Things like email, password, fullname, city, etc. I'm using ASP .NET MVC2 along with Entity Framework 4. I'm wondering if I should create a separate ProfileModel for my EditProfile View or if I should just use the User entity created by EF. My dilemmna is that if I crea...

How to add reference to a dynamic assembly for compiling another dynamic assembly?

In my AppDomain there are few dynamic assembly, when I try codeDom.CompileAssemblyFromSource to Compile another new assembly, I can't figure out a way to add those dynamic assemble to ReferencedAssemblies. foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { compilerParameters.ReferencedAssemblies.Add(assembly.L...

How to modify <head> elements programmatically?

Is there a way to programmatically access and modify the <head> section of the page in ASP.NET MVC? I need to update the page's <meta> tags depending on which data the user is viewing on any given page. ...

Add Textbox on button click

In my scenario I am building a tree structure. There are three buttons: Button number 1 - for adding parent node Button number 2 - for adding child node Button number 3 - for removing it There is a textbox which is entering the parent node. When user enter a parent node and click on button number 2 then a textbox should come under...

Routing to an Area home page in ASP.NET MVC

I'm trying to route to the home page of an Area in MVC, e.g. myDomain.com/myArea/Home/Index when I use the URL: myDomain.com/myArea MVC appears to by trying to find a Controller called "myArea" in the root Controllers folder and thereby would route to: myDomain.com/myArea/Index if the Controller existed. Again, I want: myDomai...

Deserialization problem while posting data (jQuery, json, mvc).

On my site I have simple form (by the way I'm using razor view engine): <form method="post" action="Mail/SendMailMessage" id="mailForm"> @Html.LabelFor(m => m.UserFirstAndSecondName)<br /> @Html.TextBoxFor(m => m.UserFirstAndSecondName)<br /> @Html.LabelFor(m => m.Email)<br /> @Html.TextBoxFor(m => m.Email)<br /> @Html.La...

Restrict viewing of database events to currently logged on user .Net MVC

Hi guys, I'm using this code, from the nerddinner example. This method will display a list of all the upcoming dinners in a database when called in the controller. public IQueryable<Dinner> FindUpcomingDinners() { return from dinner in entities.Dinners where dinner.EventDate > DateTime.Now orderby dinner.Event...

ASP.NET MVC 2 DropDownList Selected item changed?

I have a drop down list on my aspx form and what I want is to refresh the site after I select an item from the list. This is my drop down list: <%: Html.DropDownListFor(x => x.CompanyUserFilterId, new SelectList(Model.CompanyUsers, "Id", "FirstName", Model.CompanyUserFilterId))%> I use it to filter the data shown on the form dependin...

ASP.NET MVC UpdateModel throws exception: "Model could not be updated"

Im trying to update a simple model in MVC,but its not working,it throws an exception saying that the Model could not be updated: [HttpPost] public ActionResult SignIn([Bind(Exclude="TxtEmail")]Usuarios usuario,FormCollection fc) { try { UsuariosModel userModel = new Usuario...

Asp.Net MVC - FluentValidation

Is there a way in Asp.Net MVC to use some kind of fluent validation ? I means, instead of validation my poco like that : public class User { [Required] public int Id { get; set; } Having something like that (in an external class) : User.Validate("Required", "Id"); Is that something possible in Asp.Net MVC 2 (or 3) ? I kn...

Securing the Forms Authentication Cookie when offloading SSL

Hi, I am attempting to secure a website I am currently developing using ASP.NET MVC 2.0 and forms authentication. In order to secure the forms authentication cookie I want to set the requiresSSL property to true so the cookie is only send by browsers when the connection is under SSL, and obviously ensure that all resources which require...

How to show two strings in ASP.NetDropDownList SelectList dataTextField?

This is my DropDownList in ASP.Net: <%: Html.DropDownListFor(x => x.CompanyUserFilterId, new SelectList(Model.CompanyUsers, "Id", "FirstName", Model.CompanyUserFilterId)) %> I want to list all CompanyUsers in the DropDownList and show both their FirstName and LastName property. CompanyUsers is an IEnumerable property. The code above w...

How Add fake row in Grid helper Telerik to ASP.NET MVC

I need to add a line in the thead of table that going contenter inputs and selects that are used as parameters for filtering. It is more or less how I wanted to stay: <table> <thead> <tr> <th> Name </ th> ... <th> Type </ th> </tr> <tr> <!-- this is the 'tr fake' in th...

Disabling forward email feature (icon) of Outlook Web Access (OWA) client

I am developing ASP.NET MVC Application in which I need to integrate Exchange Server and Live@edu as a email provider for mail functionality. Now as per the requirement I need to restrict forward email feature of OWA (mail client of the Exchange Server and the Live@edu) for some user from my ASP.NET MVC application. Is it possible to co...

Where should I create my Entity Framework context object in an MVC app?

I would like to use the Session-per-request pattern, as is done frequently when using NHibernate in an ASP.NET environment. My first thought was to put the code to create the context in the BeginRequest event handler in Global.asax, but I discovered that this event is firing not only for the initial request that actually does the work...

Modify posted input values on onbegin of ajax.beginform

Hi all, I wanted to know whether I can modify posted input values on onbegin of ajax.beginform. Actually I have to modify values of some of the input fields when the form is posted, I am able to change the input fields' values but in controller action, in request.form I am getting the old values which were set in the controls when the...

Need to identify position within raw html of user text selection in browser.

I am well aware that this is an unusual thing I'm looking to do here, but just trust me, yes I do need to do this. It's all about pattern matching within the raw html (same as view source) for a web page. If a user selects some text in a web browser, I want to be able to say - that selection is at position (say) 1234, (or there abouts) ...

MVCContrib grid: Paging and Sorting execute the Controller's HttpGet method. Why?

I have a page where I have a dropdownlist which controls a grid. For this grid I use MVCContrib. When I change the value of my dropdownlist, the Controller's HttpPost method is called and this works fine. However when I page or sort the grid, the HttpGet method is called, always. Why? This is surely not how it should be? Now in the code ...

Html.RenderParial, how to pass and use the model?

I am doing this: <% Html.RenderPartial("SomePartial", Model); %> My Model has a property UserID In my partial I try this: <%= Model.UserID %> but I get this error: CS1061: 'object' does not contain a definition for 'UserID' and no extension method 'UserID' accepting a first argument of type 'object' could be found (are you missing...