:::: MENU ::::

Thursday, April 12, 2012

Note: I am uses this method over the previous post as I think it is cleaner. Firstly, you can disable client validation on your cancel button simply by adding the CSS class 'cancel' to it. See: Disable client-side validation in MVC 3 "cancel" submit button Secondly, as well as switching on the submit element's form name as described above, you can use a custom action selector. Here's mine, which I originally took from the blog post shown...
Introduction Recently, I started working on a large eCommerce website, implemented in ASP.NET MVC 3. I soon found that many of the forms in the site contained code similar to Figure 1, which I took an instant dislike to. The reason I dislike it is that "Action" doesn't relate to anything (i.e. it isn't an actual action name) and causes the URL to change when the form is submitted, so a URL like "/Blog/AddPost" will suddenly become "/Blog/Action"....