asp.net-mvc-2

REST for ASP.NET MVC included in MVC 2?

Are the REST for ASP.NET MVC bits automatically included with MVC 2, or do you need to download/install/use the REST for ASP.NET MVC bits separately? Specifically, I'm referring to the REST for ASP.NET MVC download here: http://aspnet.codeplex.com/releases/view/24471#DownloadId=79561 I want to use REST for ASP.NET MVC for the automatic...

MVC2 DataAnnotations with Server-side validation

Hi, How do you validate an entity containing DataAnnotations without using the MVC library? Using Model.IsValid is fine when you're within the Presentation layer, but what about when you want to ensure the model is valid in the Domain/Business layer? Do I need a separate validation framework, or is there an easy way I'm missing? Thank...

Best Practices For Limiting Views by Role in MVC2

What is the best way to check if a user has correct rights to run an action? I have a couple ways in my mind, some which I like more than others: 1) Use the PrincipalPermission attribute which is simple and very low on LOC written. Major con is that it requires a code release (and testing) to make any changes in security. 2) Use the A...

MVC: On partial page start validation from JS without postback

How do I start validation from the client/javascript using the MS MVC Validation library? Using MS ASP.Net MVC, I have a page with a PartialView in a modal dialog (change password). When the user selects 'save', I need to validate this on the client side without a full page postback. I am able in JS to post and refresh the partialVi...

Asp.net MVC Label For

I have the following <label for="Forename">Forename</label> <%= Html.TextBoxFor(m => m.Customer.Name.Forename) %> the problem with this is that this is rendered as <label for="Forename">Forename</label> <input type="text" value="" name="Customer.Name.Forename" id="Customer_Name_Forename"> not what I want ofc. I would like an ext...

Where is the source for the Built-In Display Templates in ASP.NET MVC 2?

Brad Wilson states that "The default templates in ASP.NET MVC are done in code." In that post, he recreates the functionality as ASCX files. Where can the code for the actual default templates be found? ...

How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

hi, How can i Set RadioButtonFor() as Checked By Default <%=Html.RadioButtonFor(m => m.Gender,"Male")%> there is way out for (Html.RadioButton) but not for (Html.RadioButtonFor) any Ideas? ...

List<string> PropertyName isn't showing up in modelState.errors

Imagine, a model like this: [AddressValidation] public AddressType[] Address { get; set; } internal class AddressValidation : ValidationAttribute { public override bool IsValid(object value) { //Assume we are valid var isValid = true; //Cast to something useful var addresses = (AddressType[]...

MVC 2 with IIS 6 Problems

Hey guys, I'm using IIS 6 on a Windows 2003 Server and I am trying to get an MVC2 project installed on that machine. I am having nightmare-ish problems doing so! I've looked up TONS of references on what to do, and not 1 single one works. (They work for MVC1 projects, as I have a few of those running already using said solutions). Does...

Exception calling UpdateModel - Value cannot be null or empty

This is probably something silly I'm missing but I'm definitely lost. I'm using .NET 4 RC and VS 2010. This is also my first attempt to use UpdateModel in .NET 4, but every time I call it, I get an exception saying Value cannont be null or empty. I've got a simple ViewModel called LogOnModel: [MetadataType(typeof(LogOnModelMD))] public ...

ASP.NET MVC2: Getting textbox data from a view to a controller

Hi, I'm having difficulty getting data from a textbox into a Controller. I've read about a few ways to accomplish this in Sanderson's book, Pro ASP.NET MVC Framework, but haven't had any success. Also, I've ran across a few similiar questions online, but haven't had any success there either. Seems like I'm missing something rather fun...

MVC noob - changing part of URL in a link

Hi, I have a site that supports localization. I would like to be able to switch between english and french. Let say the user is currently at URL: http://www.mysite.com/en/Home I would like to redirect to: http://www.mysite.com/fr/Home If the user click on a "French" link how to change the URL part to "fr" yet not change the "Home" pa...

ASP.NET MVC Futures 2 and MVCContrib 2 in the same web app / project

I have referenced both Microsoft.Web.Mvc.dll (MVC Futures 2) and MVCContrib.dll (from MVC Contrib 2), both current releases from Codeplex and I have a problem with strongly-typed RedirecToAction<>() function of Controller. It worked fine until I referenced Futures 2.. This is the compile time error. Apparently this function is implemen...

How is other content besides views handled with PortableAreas from the MVCContrib library?

I have seen blog entries like ASP.Net MVC Portable Areas - Part 2 that indicate that the build action for views must be set to Embedded Resource. What about other content such as images and CSS? Should they be set to Embedded Resource as well? Will the PortableArea ViewEngine pull that content out as well? ...

Changing the Default browser to debug in an ASP.NET MVC 2 Project

I just created my first MVC2 project using the standard template. I need to be able to change the default browser for my project to test in IE (I use chrome as the default on my OS). Unfortunately, the right click on default.aspx suggestion which worked in MVC1 can't work with these new projects as they don't have that file. ...

CruiseControl failing view compilation with Asp.net MVC 2 RTM

Tehnologies: - CruiseControlNet - Asp.net MVC 2 RTM - enabled view compilation The problem is UrlParameter.Optional setting. I can't seem to make it work when I use this setting inside a view. When I compile inside Visual Studio, everything works fine, but when CCNet uses MSBuild to compile it it fails with following error: errorCS010...

Dyanamic client side validation

Is anyone doing dyanamic client validation and if so how are you doing it. I have a view where client side validation is enabled through jquery validator ( see below) <script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script> <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> ...

How do you add a boolean attribute in asp.net mvc?

I'm trying to output the following html using an html helper in asp.net mvc 2: <input type="text" id="Name" name="Name" value="" autofocus /> I'm using this code now: <%= Html.TextBoxFor(x => x.Name) %> and I've tried // results in <input ... autofocus="" /> <%= Html.TextBoxFor(x => x.Email, new { autofocus="" }) %> // does not c...

ASP MVC2 model binding issue on POST with strongly-typed HTML helpers

So I'm looking at moving from MVC 1.0 to MVC 2.0 RTM. One of the conventions I'd like to start following is using the strongly-typed HTML helpers for generating controls like text boxes. However, it looks like it won't be an easy jump. I tried migrating my first form, replacing lines like this: <%= Html.TextBox("FirstName", Model.Dat...

my asp.net mvc 2.0 application fails with error "No parameterless constructor defined for this object"

Hello, i'm new in asp.net mvc 2. I'm trying to list all data from one table(ms sql server table). as ORM I use Entity Framework. now, I'm tried to write something to do this: Model: private uqsEntities _uqsEntity; public permissionRepository(uqsEntities uqsEntity) { _uqsEntity = uqsEntity; } public string g...