How do I handle forms in Site.Master?

I have a partial view thats being rendered in my Site.Master file (footer), and it contains a form - im able to submit values and itll throw it to the controller just fine..the problem is when validation fails and i need to go back to the form to display errors

How can i have a form that uses a viewmodel inside Site.Master and still be able to throw it back and post validation errors?

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>  

I wont be able to inherit using here...i dont think

Thanks

Answers


You could use a strongly typed partial with a form inside then pass the ModelState in TempData and add the errors back into ModelState in the partialview. I would definitely performed client side validation as well.

Another option is to submit the form via Ajax. It is very simple to do with Jquery.Forms.js

http://malsup.com/jquery/form/


Need Your Help

How to select an option field inside a table with Mechanize?

html ruby opencart mechanize

I'm trying to select &lt;option value="20"&gt;Betaling ontvangen via Bank&lt;/option&gt; from the following html code (generated by OpenCart) with Mechanize: