简体   繁体   中英

how to switch SharePoint 2010 master page for logged in user

How to switch Sharepoint 2010 depending on the logged in user?

an example :

I want to make "mycustompage.master" as master page for users in group "mysiteowners" and "v4.master" as master page for the rest of users.

thanks.

To set the master page file, use the following code

protected override void OnPreInit(EventArgs e) 
{ 
    if(UserIsInMySiteOwners())
    {
        Page.MasterPageFile = "~/mycustompage.master";
    }
    else
    {
        Page.MasterPageFile = "~/v4.master";
    }

} 

(You'll have to define your own method to determine if the user is in "Mysiteowners")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM