MVC Learning VI: "/views/shared/_layout.cshtml" of razor layout view

Source: Internet
Author: User

_layout Code:

1<! DOCTYPE html>234<meta charset="Utf-8"/>5<meta name="Viewport"Content="Width=device-width"/>6<title> @ViewBag .title</title>7@RenderSection ("Headarea", Required:false)89<body>Ten @RenderBody () One      A@RenderSection ("Bodyarea", Required:false) -      -</body> the

Use the Sub-page code for the layout page:

1 @{2     //The layout property of this page has been assigned in _viewstart.cshtml! 3Viewbag.title ="Sonpage";4 }5 6<!--sub-pages where all unused @section places are in the corresponding layout @renderbody ()--78I love Guangzhou small waist ~~~~<br/>9I love bungee jumping ~ ~ ~! Ten  One<!--corresponding to the layout @rendersection ("Bodyarea", Required:false), Required:false is not required- A @section headarea{ -I'm going to jump into a little hole, ~~~~~~~~~.!  - What are you doing to me?  the signed by: Fragrance Kids -}

All view pages use layout pages because each request executes the _viewstart.cshtml page, and the _viewstart.cshtml page assigns values to the layout properties of the page.

Many do not use the layout page will be emptied layout

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<title>TransData</title> One A<body> -</body> -

MVC Learning VI: "/views/shared/_layout.cshtml" of razor layout view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.