Presentation is loading. Please wait.

Presentation is loading. Please wait.

Layout and Partial Views

Similar presentations


Presentation on theme: "Layout and Partial Views"— Presentation transcript:

1 Layout and Partial Views
MIS Professor Sandvig 2/28/2019 Layout and Partial Views MIS 324 Professor Sandvig

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

3 MIS 324 -- Professor Sandvig
2/28/2019 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 Create like any other view
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 MIS 324 -- Professor Sandvig
2/28/2019 Summary Benefits of Layouts & Partial Views Reusable UI code Easy to use


Download ppt "Layout and Partial Views"

Similar presentations


Ads by Google