AlternateHeader magic to style your SharePoint pages

Both in the portal and in team sites the underlying functionality is managed by an SPWeb. SPWeb functionality uses many generic ASPX pages defined in the folder Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\1033. All pages in this directory look at the SPWeb property AlternateHeader. This property can be used to set the URL for an alternate .aspx page to use for rendering the top navigation area in SharePoint pages. Each ASPX page in this directory contains code to determine if the default header must be rendered or the specified header. it contains code like:

<%
string alternateHeader = SPControl.GetContextWeb(Context).AlternateHeader;
if (alternateHeader == null || alternateHeader == "")
{
%>
<TR><TD WIDTH="100%" COLSPAN="3"><!--Top bar-->
<TABLE class=ms-bannerframe cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=center noWrap><IMG id=onetidHeadbnnr0 alt=Logo src="/_layouts/images/logo.gif"></TD>
<TD class=ms-banner id=HBN100 vAlign=center noWrap width="99%"><!--webbot Bot="Navigation" startspan--><?XML:NAMESPACE PREFIX = SharePoint /><SharePoint:Navigation runat="server" LinkBarId="1002"></SharePoint:Navigation></TD>
<TD class=ms-banner>&nbsp;&nbsp;</TD>
<TD class=ms-banner style="PADDING-RIGHT: 7px" noWrap><SharePoint:PortalConnection runat="server"></SharePoint:PortalConnection></TD></TR></TBODY></TABLE></TD></TR>
<%
}
else
{
    Server.Execute(alternateHeader);
}
%>

Normaly this AlternateHeader is empty, but all SPWebs underlying the areas in the portal have this property set to PortalHeader.aspx, and all MySites have this property set to MySiteHeader.aspx. These files can be found in the folder Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\1033.

PortalHeader.aspx:

<%@ Page language="C#"     Inherits="Microsoft.SharePoint.Portal.SiteAdminPageNoBrowserCheck,Microsoft.SharePoint.Portal,Version=11.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<tr> <td colspan="3" width="100%">
 <SPSWC:PageRedirectControl runat="server" />
 <SPSWC:ExternalHtmlResourceElement runat="server" HtmlElement="StylesheetLink" FileContext="SharedStyle" FileName="ows.css" />
 <SPSWC:ExternalHtmlResourceElement runat="server" HtmlElement="StylesheetLink" FileContext="SharedStyle" FileName="menu.css" />
 <SPSWC:ExternalHtmlResourceElement runat="server" HtmlElement="StylesheetLink" FileContext="SharedStyle" FileName="sps.css" />
 <SPSWC:CustomCSSResourceElement runat="server"/>
 <SPSWC:PageHeader id="PageHeaderID" runat="server" PageContext="SitePage" ShowTitle="false" HelpID="NavBarHelpHome"/>
 <div class="ms-phnav1wrapper ms-navframe"> <SPSWC:CategoryNavigationWebPart runat="server" id="HorizontalNavBar" DisplayStyle="HorizontalOneLayer" /> </div>
</td> </tr>

MySiteHeader.aspx:

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SPSWC:PersonalSpaceNavigationResponse runat="server" />
<tr><td colspan="3" width="100%">
 <SPSWC:PersonalSpaceNavigation runat="server" />
</td> </tr>

 

Published Tuesday, June 01, 2004 11:24 PM by svdoever
Filed under:

Comments

Wednesday, June 02, 2004 1:12 AM by MJA

# re: AlternateHeader magic to style your SharePoint pages

I have been trying to work with this today so this post is very timely. However, I have two questions:

1. What setting controls this for pages in the layouts\1033 directory like listedit.aspx, etc. ? In other words, for admin pages, where can this alternateheader value be specified.

2. When I try to add my own custom web parts to the portalheader.aspx page I get the famous "safe control" error. How can you add custom web parts (normally deployed to the bin dir) to this aspx?
Wednesday, June 02, 2004 3:03 AM by Eric Donneger

# re: AlternateHeader magic to style your SharePoint pages

Let me say it is not as cool as you're thinking because only aspx pages used by WSS AND SPS implement this alternateheader code. If you look at some portal specific page (speditcategory.aspx for example) you'll see that the header is designed in this aspx page itself.

alternateHeader or even alternateCSS attribute of CAML definition for portal areas is not used in these specific pages. This is a big problem when trying to custom portals.
Wednesday, June 02, 2004 5:36 AM by Serge van den Oever, Macaw

# re: AlternateHeader magic to style your SharePoint pages

MJA, These pages are executed within the context of the web, if you look at the code you see how the alternate header is retrieved:

string alternateHeader = SPControl.GetContextWeb(Context).AlternateHeader;

So these pages use the AlternateHeader setting of the site they are executed in.

About you second question: this is the security model of SharePoint, have a look at the MSDN site and looke at the SharePoint CAS article, or any article on building web sites. The assemblies used in your web part must be added as safecontrols to the web.config.
Wednesday, June 02, 2004 7:09 AM by Serge van den Oever, Macaw

# re: AlternateHeader magic to style your SharePoint pages

Eric, the portal specific pages use another mechanism using the tag: <SPSWC:PageHeadTags id="PageHeader" runat="server" TitleLocId="SiteAdminMoveListing_PageTitle_Text" OldExpires="0" PageContext="SiteAdminPage" PageType="Portal" />. This tag renders the needed stylesheets. Changes in the portal should be done through stylesheet changes only, otherwise you really get into trouble. You have to modify all templates and pages, and some pages use server controls only and can't be properly modified.

An approach I'm currently researching is to apply regular expression replacements on the HTML as ouputted by all ASPX pages using a httpmodule. Seems to be the only approach to get modifications to the actual code really working.

Friday, June 04, 2004 9:36 PM by Giles

# re: AlternateHeader magic to style your SharePoint pages

Hi Serge,

great post, quite a bit of portal detail of which I was unaware. The only problem with the alternate header is that none of the web part pages or list pages use it, only admin pages under the _layouts directory.

If I read your feedback right you're building a httpmodule to get around this?

I've added a few pointers on my own blog with when having to restart iis with editing ONET.XML. Hopefully save a few others the pain..

and it's my first post of useful information :-)
Wednesday, June 16, 2004 4:12 AM by TrackBack

# Cool SharePoint Stuff

Thursday, June 17, 2004 3:43 AM by Linda

# re: AlternateHeader magic to style your SharePoint pages

Good article!

Only one question, for those aspx designing header by itself, how to customize their headers? any good approach?
Thursday, June 17, 2004 3:48 AM by TrackBack

# AlternateHeader magic, Reporting Services Web Parts

Linked
Tuesday, June 22, 2004 9:02 AM by Sunil R. Warrier

# re: AlternateHeader magic to style your SharePoint pages

For the main home page where we can find the onet.xml ? I tried renaming all onet also still postal is working same. And I made changes in portalheader.aspx, I did't noticed any changes in any pages. I tried even iisreset also.
I believe I am missing something

Other than this mothered I may have to change 100s of pages in frontpage

Any help will be appreciated,

Thanks

Sunil
Thursday, June 24, 2004 7:21 AM by NickyW

# re: AlternateHeader magic to style your SharePoint pages

Hi Serge,
This topic really interests me, can you explain a bit more about this.
a) First where do I set the AlternateHeader to point to a new page? (I'm guessing ONET.xml)
b)Will this effect existing areas and subsites or just new ones?
c)If make some changes to portalHeader.aspx or mySiteHeader.aspx should these changes appear in existing or new sites/areas? (I've tried and they don't seem to)
Thanks for your help,
Nicky
Tuesday, July 13, 2004 9:56 PM by TrackBack

# How to create Mysite programmatically / Alternate Header again

Tuesday, July 13, 2004 9:59 PM by TrackBack

# How to create Mysite programmatically / Alternate Header again

Thursday, August 19, 2004 4:51 AM by TrackBack

# Doing simple adjustments to the Sharepoint Portal Area pages

# Share Points &raquo; Blog Archive &raquo; Using alternate header in ONET.XML

Thursday, August 17, 2006 9:47 PM by lorazepam

# lorazepam

Wednesday, May 30, 2007 6:40 PM by Stether

# re: AlternateHeader magic to style your SharePoint pages

cigarettes.blogbugs.org - cigarettes blog

Friday, December 07, 2007 8:53 AM by Amar Galla's Weblog

# How to brand a SharePoint Portal or Site for best results - Part 3

I have been a bit slow in posting on this series. Enjoying my holidays and relaxing most of the time

Wednesday, December 03, 2008 1:48 AM by Asina

# re: AlternateHeader magic to style your SharePoint pages

<a href= bestpre.com ></a>

Friday, December 05, 2008 11:52 PM by Semil

# re: AlternateHeader magic to style your SharePoint pages

<a href= spiritez.com ></a>

Saturday, December 06, 2008 3:38 PM by Semil

# re: AlternateHeader magic to style your SharePoint pages

<a href= spiritez.com ></a>

Friday, December 26, 2008 6:18 AM by garry-mf

# re: AlternateHeader magic to style your SharePoint pages

<a href= membres.lycos.fr/dertull >zx10r graphics</a>

# Portal customization followthrough in the wss sites. | keyongtech

Pingback from  Portal customization followthrough in the wss sites. | keyongtech

Wednesday, April 29, 2009 6:28 PM by Mery-gt

# re: AlternateHeader magic to style your SharePoint pages

<a href= <div align=center><h3>Error. Page cannot be displayed. Please contact service provider for more details.</h3></div> ></a>

Leave a Comment

(required) 
(required) 
(optional)
(required)