Sunday, March 16, 2008

SharePoint: Link to top of site collection

To link to the top level of a site collection, include an anchor link with SharePoint-specific processing instructions such as this:

<a href="<% $SPUrl:~SiteCollection/%>" runat="server">Intranet</a>

Make sure to include the runat="server" to force the control to be processed on the server and not the client. Otherwise, you will get an error like this:

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.


Parser Error Message: Literal expressions like '<% $SPUrl:~SiteCollection/%>' are not allowed. Use <asp:Literal runat="server" Text="<%$SPUrl:~SiteCollection/%>" /> instead.

0 comments: