1. Chaning the Master page for a particular browser.
2. Changing the Master Page for a particular set of users.
The following code programmatically switch to the Pocket PC friendly master page when a "Windows CE" (pocket pc) browser is detected. In the following code, the master page, pocketpc.master, changes the layout, hides some of the content and references a CSS file with fonts and layout which are better suited for the smaller form factor of a pocket pc.
protected void Page PreInit(object sender, EventArgs e) {
if(Request.Browser.Browser.ToLower.Contains("windows ce")){
this.MasterPageFile = "~/pocketpc.master";
}
else {
this.MasterPageFile = "~/MasterPage.master";
}
}
For second problem we can find the users with the help of SPUser class and then assign the Master Page.
1 comment:
Hi,
If I want to change in my own page then I can write the code in PreInit method. But if I want to change the master page for all pages (event in sharepoint pages) then how will I do so?
Thanks
Sohel Rana
Post a Comment