How to render JavaScript into MasterLayout section from partial view?

前端 未结 3 1224
小鲜肉
小鲜肉 2020-12-01 08:34

Given MVC3 and Razor engine, I got

_MasterLayout.cshtml

@RenderSection(\"JavaScript\", required: false)
..
..
@RenderBody()
..
         


        
3条回答
  •  暖寄归人
    2020-12-01 09:05

    I don't believe a Partial View can set sections to be used in the layout page :(

    It looks like there are no nice solutions to this - you could include two partials (one for script, one for content):

    
    
    @Html.RenderAction("PartialView", "PartialController")
    
    

提交回复
热议问题