开发者

how to loading part of layout dynamically

how can i have a section (for exam开发者_Python百科ple a sidebar) that will load at the first time in the layout depends on user's login information. and become part of the layout and do not need to post it back every time. and also do not need to read it from @viewBag because changes in sidebar (opened and closed tabs of sidebar by the user) will revert to it's defaults! and of course not using RenderSection() because i have to create that section in every views! my question is: how can i dynamically add a simple <div>....</div> tag to the layout at runtime without using @viewBag or rendersection?


In your layout, you can have an optional section:

@RenderSection("OptionalContent", required: false)

Then you can create the section in just the views that you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜