ContentPlaceHolder in Razor?

前端 未结 2 740
长发绾君心
长发绾君心 2020-12-05 12:49

I can use ContentPlaceHolder\'s with Webforms view engines to put stuff in different locations in the master page.

How do I do that with Razor?

    &         


        
相关标签:
2条回答
  • 2020-12-05 13:15

    Couldn't leave a comment sorry but you can remove the "required:"

    @RenderSection("footer", false)
    
    0 讨论(0)
  • 2020-12-05 13:23

    Yet again I managed to ask before finding the correct search keywords in Google.

    In the layout

    @RenderSection("footer", required: false)  
    

    View example

    <h2>About</h2> 
    
    <p>   
        Some stuff about this page.   
    </p> 
    
    <p> 
        The current date and time: @DateTime.Now  
    </p> 
    
    @section footer { 
    
        Copyright (c) 2010, Robert Sundström. 
    
    }
    
    0 讨论(0)
提交回复
热议问题