开发者

How to set default Master Page dynamically

开发者 https://www.devze.com 2023-02-12 22:45 出处:网络
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

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

精彩评论

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