ASP.NET MVC 3: Layouts with Razor
page 7 of 10
by Scott Guthrie
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:


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:


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


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


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:


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


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  |  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