1 / 11

Layout and Partial Views

Layout and Partial Views. MIS 324 Professor Sandvig. Overview. Layout View Define page layout once Inject dynamic content Partial Views Define “part of page” Use on multiple pages. Goal. Reusable UI code. Classes. Code. Reusability Modularity. Interface. Layout & Partial Views.

agilbert
Download Presentation

Layout and Partial Views

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Layout and Partial Views MIS 324 Professor Sandvig

  2. Overview • Layout View • Define page layout once • Inject dynamic content • Partial Views • Define “part of page” • Use on multiple pages

  3. Goal • Reusable UI code Classes Code • Reusability • Modularity Interface Layout & Partial Views

  4. Layout View Source: tutorialsTeacher.com

  5. Layout View • Layout view contains shared UI • Current view injected: • @RenderBody() • Been using Layout View • Views folder • _ViewStart.cshtml

  6. Layout View • Three ways to specify which layout to use • _ViewStart.cshtml • Layout Razor tag in each page • In ActionMethod

  7. Layout View _ViewStart.cshtml in View folder

  8. Layout View Action Method public ActionResult Index() { return View("Index", "_myLayoutPage"); }

  9. Partial Views • Reusable UI code • Headers, footer, navigation, etc. • Create like any other view • Check Partial View • Adds: Layout = null; • Add to layout • @Html.Partial("_header")

  10. Partial Views • Can fire action methods for dynamic content • @Html.Action("_leftMenu") • Example: Layout and Partial Views

  11. Summary • Benefits of Layouts & Partial Views • Reusable UI code • Easy to use

More Related