asp.net-mvc-2

Are <%: and <%= the same thing as embbed code (expression) blocks

Having just started with MVC 2 I notice that in their starter template they use <%: Html.ActionLink("Home", "Index", "Home")%> and I was sure that in MVC 1 it was <%= Html.ActionLink("Home", "Index", "Home")%> Are they the same thing? If so, why the change from equal sign to colon. ...

MVC 2 - Name Attributes on HTML Input Field when using Parent/Child Entities

Hi All, I'm pretty new to MVC 2 using the Entity Framework. I have two tables Company {ID int identity PK,Name nvarchar} and User {ID int identity PK,UserName nvarchar,CompanyID int FK}. A Foreign Key exists between User and Company. I generated my ADO.NET Entity Data Model, a Controller and a view to insert a record. My HTML form has...

RenderPartial missing from Html Helper in ASP.NET MVC 2

I've just converted an application from MVC 1 to MVC 2 using the VS2010 wizard. Not found is the Html.RenderPartial which I have sprinkled around a number of views. I am guessing that this is something that I've done wrong because I see no mention of this as a breaking change in the white papers and docs. Everything I'm using is RTM/RTW ...

implementing ValidationMessageFor

I was working on migrating MVC1 app to MVC2 today and i have come across a problem while changing the ValidationMessage to ValidationMessageFor implementation. The below is the selectlist in my View <%=Html.DropDownListFor(model => model.SecurityQuestions[0].Question, "Some Security question", new { @class = "form_element_select" })%>...

What is the best practice for mvc2 confirm password field?

I have asked a similar question recently but getting no answers i am taking a step back with a more broad approach. I am looking to create a confirm password field using asp.net MVC2 that works on the client. All my other client validation is done with MicrosoftMvcValidation.js by just adding the Html.EnableClientValidation(); call. S...

How to include the login form on the Home index page in MVC

Hi guys I really need your help for this. I am relatively new to programming and I need help to something that could be easy for a experienced programmer. I would like to get the login form that we get for free in an MVC application on the left sidebar of my Home index page instead of the usual Account/Login page. I am facing some pro...

No styles / images on asp.Net MVC 2 application

Greetings i have a little problem with my ASP MVC application. On my local development server everything works just fine but when i try to publish the application to an IIS 7.0 server it just displays plain pages without any styles / markups / images. I put all those things in the /Content/ subfolder but when i try to access that folde...

Is there a way I can still use app_offline.htm on my ASP.NET MVC 2 projects? If not, is there an alternative method?

I loved the features of using app_offline.htm on my ASP.NET WebForm based sites. Upload the file and your app is immediately "offline". Snappy. Now that I'm using MVC 2, I noticed that this no longer works. Is there a way to get this behavior in ASP.NET MVC 2 like it did in WebForms? If not, what alternative do you prefer? ...

Is there a way to debug ASP.NET MVC code using a symbol server (instead of downloading the source and referencing that)?

Hi folks, Is it possible to step through the official ASP.NET MVC 2 code via using the Symbol Server thingy in visual studio 2010? I know I can download the full open source MVC code from codeplex, build it and then get my code to reference THAT codebase dll's... But i'm wondering if this could be achieved by using the Symbol Server s...

Having all Views in the Shared folder - works but is throwing "caught exceptions". Performance concern??

Hi everyone, I have a simple but heavily used app done in VS2010/MVC2. I didn't like having separate folders for each view/controller and so have all the views in the Shared folder. It's working fine but while debugging in VS, I noticed that it's throwing IO "caught exceptions" since it seems to be looking in the [FolderName]/[ViewNam...

LazyList<T> vs System.Lazy<List<T>> in ASP.NET MVC 2?

In Rob Conery's Storefront series, Rob makes extensive use of the LazyList<..> construct to pull data from IQueryables. How does this differ from the System.Lazy<...> construct now available in .NET 4.0 (and perhaps earlier)? More depth based on DoctaJones' great answer: Would you recommend one over the other if I wanted to opera...

How can I create a generic UniqueValidationAttribute in C# and DataAnnotation?

I'm trying to create a UniqueAttribute using the System.ComponentModel.DataAnnotations.ValidationAttribute I want this to be generic as in I could pass the Linq DataContext, the table name, the field and validate if the incoming value is unique or not. Here is a non-compilable code fragment that I'm stuck at right now: using System; u...

jQuery WCF Service MVC2 VS2010 .NET 4.0 call with parameters fails

In Visual Studio 2010 I created a new Ajax enabled WCF Service [ServiceContract(Namespace = "TestWCFAjax.Bridge")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Bridge { [OperationContract] public string DoWork() { return "jQuery WCF call without parame...

Conditionally embed ASP.NET MVC2 Views as resources during build in Visual Studio 2010

I have a ASP.NET MVC2 project in VS2010 that can be deployed in two modes: standalone or plugin. In standalone mode, the views should live outside the compiled assembly as .aspx files (the default setup). In plugin mode, the views are switched (currently by hand) to embedded resources and the entire assembly is dropped into a host proj...

The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'

After converting a Hybrid ASP.NET MVC1 app to MVC2 I'm getting the following error when I try and run the application: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) The allegeded culprit in the web.config file is System.Web.Mvc: <namespaces> <add namespace="S...

Top 5 reasons for using ASP.NET MVC 2 rather than ASP.NET MVC 1

I've been using ASP.NET MVC 1 for a while now, and am keen to take advantage of the improvements in MVC 2. Things like validation seem greatly improved, and strongly-typed HTML helper methods look great. So, for those of you who have real-world practical experience of using ASP.NET MVC 1 and are now using MVC 2, what are your top 5 rea...

How to auto-generate simple CRUD controllers and views in ASP.Net MVC 2 (VS2010) Entity Framework project?

I have a standard template "ASP.NET MVC 2 Web application" solution, an empty (meaning no data inserted, but with all tables etc. ready and waiting) SQL Server database, an Entity Framework 4 model (edmx). Is there a way to generate simple CRUD controllers and form views for all the entities in the model? ...

ASP.Net MVC 2 DropDownListFor in EditorTemplate

I have a view model that looks like this: namespace AutoForm.Models { public class ProductViewModel { [UIHint("DropDownList")] public String Category { get; set; } [ScaffoldColumn(false)] public IEnumerable<SelectListItem> CategoryList { get; set; } ... } } It has Category and Cate...

Validate two properties against each other in ASP.NET MVC2, with DataAnnotations

For example, I'd like to validate a user registration form and check whether user has entered his password in "password" and "confirm password" fields, AND that those two values are the same. Found this but is reflection really the only way? ...

ASP.Net MVC 2 - Need To Add A Default Property To A Strongly Typed Html.Textbox Helper In Asp.Net MVC 2

I'm having a problem with something that I'm sure is very simple. I have been using Asp.Net MVC and I decided to start using Asp.Net MVC 2. Something has changed and now I need a little help. The strongly typed helpers are now written like this - <%= Html.TextBoxFor(model => model.State) %> I need to add a default value to a textbox....