ASP.NET MVC 3: Layouts with Razor
page 7 of 10
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 49288/ 81

Finished Sample

Below is a screen-shot of the simple application we have been building:

image

Here is the ProductsControllers that implements the /Products URL and retrieves the categories from a database and passes them to a view template to render:

image_thumb_579C4852[1]

Here is the Index.cshtml view that we are using the render the /Products response:

image

Here is the SiteLayout.cshtml layout file we are using to implement a consistent look and feel across our site:

image

Here is the _ViewStart.cshtml file that we are using to specify that all views in our site by default use the SiteLayout.cshtml file:

image

And here is the generated HTML from the /Products URL:

image

And because we now have a common layout file for our site, we can build out more functionality, controllers and views within our application - and have a site UI experience that is both consistent and very easy to maintain.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-25 10:24:11 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search