asp.net-mvc

Common Data Properties In ASP.NET MVC 2 Data Objects

Okay, I've been struggling with this for a while now. I have a standard MVC2 project and use EF4 to access data objects. Many of my data objects (and therefore database tables) have two common fields: UpdateUserAccountID and UpdateDate. In each of my controllers, I am currently setting this fields manually within each controller on the...

Asp.Net MVC Virtual Area

Is there such a thing? I have two projects within the same solution. When I run the solution within Visual Studio two separate instances of localhost are launched. project foo is available at http://localhost:3091 and project bar is available at http://localhost:3094 I would like to have access to project bar within foo for example...

Need to pass a querystring variable in MVC, so i can use it with jquery?

SO i would like to create this url blah.com/preview?h=yes so i can do this <% if request.querystring("h") = "yes" then %> jquery stuff <% else %> don't do jquery stuff <% end if %> ...

ASP.NET MVC problem using image submit tag in Ajax.BeginForm

I'm developing a web app with ASP.NET MVC 2 (.NET 4.0), and I've run into a difficult problem. I've got the following code in a partial view: <% using (Ajax.BeginForm("CompleteTask", "Agenda", new AjaxOptions {HttpMethod = "POST"})) { %> <%: Html.EditorFor(x => x.Remarks) %> <%: Html.HiddenFor(x => x.TaskId) %> <%: Html.Hid...

How do you access the type a ViewUserControl expects at runtime?

If you have: System.Web.Mvc.ViewUserControl<T> how do you access T at runtime? I have a base class which I pass into Html.RenderPartial("ViewName", BaseControlModel); but I want to create another extension method such as Html.RenderTypedPartial("ViewName", BaseControlModel); such that in the context of ViewName.ascx my BaseCon...

Rendering one partial view in two different strongly typed views

I have a strongly typed Person view, that I want to render a partial in: Person View (strongly typed as person) <label for="name">Name</label> <% Html.RenderPartial("AddressForm"); %> </label> AddressForm View (untyped, because I also want to use this in the Distributor strongly typed view) When I try to call this partial from t...

How can i tell if a radiobutton is checked in action ? (MVC)

I would really like to be able to do this if myRB.Checked = true then return redirecttorout("SomeRoute") else someother route i am used to web forms, in which i could do this in the code behind ...

Problem with TempData and Faked HttpContext using ASP.NET MVC

Hi Everyone, I am working with a faked HttpContext (code provided in the end) and probably I am missing something because I can't access TempData collection (forth line of SetFakeControllerContext method). Every time I try I get this error message: 'controller.TempData' threw an exception of type 'System.AccessViolationException' The ...

How do I reset to default drop down list option on refresh(F5) in Firefox?

I have a ddl in firefox that does not get reset to the default caption. How do I do this? This is what I have so far. <%string ddlVal = ""%> <select id="detailSelect" name="DetailSelect"> <option <%if (ddlVal == "") { Response.Write("selected = &quot;selected&quot;"); } %> value="" >--Choose One--</option> <option <%if (ddlVal =...

Is it good and safe to use Json object to submit form data? I am using MVC 2 with JQuery Post

In my ASP.Net MVC 2 application I am using a Json object to submit form data. I would like to take expert advice whether it is a safe and good practice to do it or not and why? Please note, this question is not about how to do it but rather about best practice. Appreciate your valuable suggestions. ...

How do you handle line breaks in HTML Encoded MVC view?

I am unsure of the best way to handle this. In my index view I display a message that is contained in TempData["message"]. This allows me to display certain error or informational messages to the user when coming from another action (for example, if a user tries to enter the Edit action when they don't have access, it kicks them back t...

Unable to reference CSS properly in Site.Master with MVC2 in a Virtual Directory

Currently, I have a Site.Master page for my MVC app that renders great when run directly from VS2008. It looks like this: <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/19...

Table prefix for MySqlMembershipProvider

I have MySqlMembershipProvider working with Asp.Net MVC. My question is how can I configure the table prefix... so instead of 'my_aspnet_' prefix on the tables, I want this to be either none or defined by me. My web.config: <?xml version="1.0"?> <add name="ApplicationServices" connectionString="server=localhost;user id=root;P...

The "Model" in .Net MVC

How do data frameworks such as Linq 2 SQL, ADO.Net Data Entities and DataSets relate to the "Model" as defined by .Net MVC. The reason I ask is I'm trying to learn the ins and outs of the .Net framework without relying on many of the tools that make it easy and hide the workings from you. The "model" I'm building in my exploratory app ...

sAjaxSource doesn't get executed in IE

I am using jquery datatables serverside in my MVC application. When I put a break point to my controller method “FillTable” the execution only reaches on the first occasion on IE. If I go back and reload the page and the data is different the function doesn’t get called. When I try Firefox the break point is hit on each reload without an...

Entity edit form with Reference to another entity by drop down list

My issue involves updating an entity via an edit form with a reference to another entity represented by a drop down list. I'm using ASP.NET MVC 2. Details: Public Class Category { int Id { get; set;} string Name { get; set} Category Parent { get; set} } An edit page for the category generated by EditorFor Edit page contain...

Adding extra url parameter causes jquery error

Intro I'm developing a project with MVC.Net. I have just started a default website with a Home Controller and an Index action. I browse to the view with 'Home/Index/1' and everyting works fine. Now I want to add an extra url parameter, so I've changed my global.asax and added a foo parameter: routes.MapRoute( "Default", // Route na...

How to target asp.net MVC 1 when version 2 is installed on build machine

Hi There, I have a site that was built using asp.net MVC version 1. I recently upgraded to visual studio 2010 which includes version 2. Upon opening the site now, I see that it believes the runtimes for MVC for this project are at version 2 so when I publish to my server, it fails as it cannot find version 2. Installing MVC 2.00 is not...

ASP.NET MVC: Route with optional parameter, but if supplied, must match \d+

I'm trying to write a route with a nullable int in it. It should be possible to go to both /profile/ but also /profile/\d+. routes.MapRoute("ProfileDetails", "profile/{userId}", new {controller = "Profile", action = "Details", userId = UrlParameter.Optional}, new ...

Storing validationmessages in database

Hello I currently have a resource-file where I store "errormessages". And I would like to change it so it uses database. I have functions that returns from database. Whats needed to do more in my class besides the "retrieve-error"-part to use it like I did before: [Required(ErrorMessageResourceType = typeof(ErrorMessages), ErrorMessage...