开发者

How to set default Master Page dynamically

I have two master pages. When the user logs in it should set first m开发者_如何学Goaster page as default master page. If other login it should set second master page.


You can specify the default master page to use in the web.config file, using the masterPageFile attribute of the pages element:

<system.web>
  <pages masterPageFile="~/DefaultMaster.master" />
  <!-- more configuration goes here... -->
</system.web>

The page will use that master page unless it has a MasterPageFile specified.


As @RoBYCoNTe pointed out in the comments, you can set the MasterPageFile property on your pages.

If each page inherits from a common BaseClass, you can set the MasterPageFile property in your BaseClass to avoid having to do it on each individual page.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜