[HttpGet] – send initial blank form
[HttpPost] – process posted data
//Render view “Thanks” and pass the object to it.
return View(“Thanks”, guestResponse)
Print the text after @:
page 35, 03/02/2013, 05:49pm
In MVC, validation is applied at the domain model, not user interface.
If you want to make a bool field required, then make it a nullable field!!
If the client returns NULL, then the Required attribute will report an error.
Because of model binding – the previously enter value will be displayed along with the error messages.
If a field does not pass the validation, the HTML for that fields will have this class defined:
IQuerable<T> is derived from IEnumerable<T>
Chapter 5 – Working With Razor
File in the /View folder that begins with an underscore (_) is not returned to the user.
Add a new layout page by :View –> Add –> New item –> MVC 4 Layout Page.
To use the new layout page in a view:
Or, if you want to include this layout in all views, create another special view called _ViewStart.cshtml and include this code:
Then you won’t need to include reference to the layout page in every view.
Page 109, 03/04/2013, 09:41pm