While doing Sharepoint branding or skinning you may notice that Sharepoint default master page styling does not apply to its admin pages.
For example, admin page like "View All Content" will remain as is because admin pages served via _layouts folder use different master page i.e. application.master which resides in the same _layouts folder.
So, in order to use same default.master or any other custom master page from main portal to the pages served through _layouts you need to perform following steps:
1. Place following code in the related aspx file e.g. in viewlsts.aspx of _layouts folder
<script runat="server" type="text/C#">
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
SPWeb myWeb = SPControl.GetContextSite(Context).OpenWeb();
string strUrl = myWeb.ServerRelativeUrl + "/_layouts/custom.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;
}
</script>
2. Add 2 extra contentplaceholders into your custom.master file. Here are the two extra placeholders:
PlaceHolderPageDescriptionRowAttr
PlaceHolderPageDescriptionRowAttr2
To add these placeholders into custom.master replace following code:
<PlaceHolder id="MSO_ContentDiv" runat="server">
<table id="MSO_ContentTable" width=100% height="100%" border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet">
<tr>
<td class='ms-bodyareaframe' valign="top" height="100%">
<A name="mainContent"></A>
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</PlaceHolder>
with
<PlaceHolder id="MSO_ContentDiv" runat="server">
<table id="MSO_ContentTable" width=100% height="100%" border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet">
<TR valign="top" <asp:ContentPlaceHolder id="PlaceHolderPageDescriptionRowAttr" runat="server"/> >
<TD class="ms-descriptiontext" width="100%">
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server"/>
</TD>
</TR>
<TR <asp:ContentPlaceHolder id="PlaceHolderPageDescriptionRowAttr2" runat="server"/>>
<TD ID=onetidMainBodyPadding height="8px"><IMG src="/_layouts/images/blank.gif" width=1 height=8 alt=""></TD>
</TR>
<tr>
<td class='ms-bodyareaframe' valign="top" height="100%">
<A name="mainContent"></A>
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</PlaceHolder>
3. Also change default breadcrumbs code to match the application.master - Replace following code:
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
<asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
</asp:ContentPlaceHolder>
with
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
<asp:SiteMapPath SiteMapProvider="SPXmlContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
</asp:ContentPlaceHolder>
That's it!
Another useful approach is to use custom httpModule but this approach is simpler if you want to change few admin pages skin.