Pro asp.net mvc 4 (1)

image
image
Page 30

[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 @:
@:Hello world!

page 35, 03/02/2013, 05:49pm

include the model in the first line
image
image

Adding Validation
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.
image
image
image
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:
image

Chapter 3 – MVC Pattern
image
Chapter 4 – Essential Language Features
image
image

Extension Method: Convenient way to adding new method to classes that you don’t own and so cannot modify directly.
image
How to use the extension method – just like anything else!
image
Using LINQ to get products
image
image

Deferred – method is not executed until the items in the results are enumerated.
image

image

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:
image
Or, if you want to include this layout in all views, create another special view called _ViewStart.cshtml and include this code:
image
image
Then you won’t need to include reference to the layout page in every view.
Page 109, 03/04/2013, 09:41pm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s