How can I set a variable on a _Layout page?

后端 未结 3 1543
温柔的废话
温柔的废话 2021-02-13 19:01

I have a view and I want to use a layout page. In the layout page I want to have a conditional banner which some of the view will turn on/off. Just wondering how I can do this?<

3条回答
  •  我在风中等你
    2021-02-13 19:26

    You can define a SECTION in your Layout, and then if your View is responsible to "fill" that section... your view can place the HTML in that section.

    Here you can see a detailed step by step tutorial on using SECTIONS:

    http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx

提交回复
热议问题