2

I have switched a site back to use UI version 3, so this basically works as a 2007 site would.

I would expect that when accessing application pages this would use the application.master in the layouts folder. It doesn't, how do i know this? Well i edited the application.master in the layouts folder with

Hello World

and when i open an application page, the edited application.master is not showing.

Can anyone tell me what master page it is using, driving me a little crazy!

1
  • Is it not using the v4.master or default.master from the GLOBAL folder?
    – Colin
    Sep 14, 2011 at 9:46

2 Answers 2

2

Are you sure the page you were testing wasn't using the simple.master?

What _layouts page where you using to test?

If you are interested, I wrote a httpmodule for 2007 that would set the applicationpage master to be what the web's master was set to, for the consistant experience: http://www.thelineberrys.com/default-category/using-your-sharepoint-sites-master-page-on-all-application-pages-3.html

I did have to make a change to the code to get it to work as expected in SP 2010 using UIVersion 3 (because with UIVersion 4, there is an option to do this OOTB in your web application general settings).

Below is the new preinit that works with SP 2010:

void page_PreInit(object sender, EventArgs e)
{
    LayoutsPageBase page = sender as LayoutsPageBase;
    if (page == null) return;
    if (page.DynamicMasterPageFile == null) return;

    HttpContext context = HttpContext.Current;
    string currUrl = context.Request.Url.ToString();
    string basepath = currUrl.Substring(0, currUrl.IndexOf(context.Request.Url.Host) + context.Request.Url.Host.Length);
    //Use RawUrl, otherwise it will always use the root web.
    currUrl = context.Request.RawUrl;
    if (currUrl.ToLower().Contains("/_layouts/") &&
        (page.DynamicMasterPageFile.ToLower().EndsWith("default.master") ||
        page.DynamicMasterPageFile.ToLower().EndsWith("custom.master")))
    {
        currUrl = currUrl.Substring(0, currUrl.ToLower().IndexOf("/_layouts/"));
        SPSite site = null;
        SPWeb web = null;
        try
        {
            site = new SPSite(basepath + currUrl);
            web = site.OpenWeb(currUrl);

            if (String.IsNullOrEmpty(web.MasterUrl) == false &&
                web.UIVersion == 3)
            {
                page.MasterPageFile = web.MasterUrl; 
                page.Load += new EventHandler(page_Load);
            }
        }
        finally
        {
            if (web != null)
            {
                web.Dispose();
            }
            if (site != null)
            {
                site.Dispose();
            }
        }
    }
}
0

master pages are in \14\TEMPLATE\GLOBAL folder.

Try to edit them by SharePoint Designer instead of editing files directly in folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.