Using Custom Masterpage in _layouts directory
August 24th, 2009 by Matt
To use a custom or the default masterpage in custom aspx pages located in your _layouts directory use the following code in the code behind for the page.
N.B I didn’t declare any masterpage useage in the actual aspx file.
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Set the masterpage to the default.master. using (SPWeb webCurrent = SPControl.GetContextSite(Context).OpenWeb()) { string strUrl = webCurrent.ServerRelativeUrl + "/_catalogs/masterpage/default.master"; // custom.master is your same default or main master page // being used for main portal pages. Change that path according to your need this.MasterPageFile = strUrl; } }
Posted in Mobile, SharePoint
October 30th, 2009 at 3:07 am
I am getting access denied page for non admin user after using this method.
I also tried runwithelevatedprivilages method but no luck
any suggestions