Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Any $spurl experts?

  Asked By: Johanna    Date: Aug 16    Category: Sharepoint    Views: 3651

I'm reading about the $spurl syntax to refer to root level site
collections when referencing assets in your Masterpages.

I'm running into two issues:

1) If I use the example as shown in the 'real world' book:

<asp:image runat="server" ID="logo" ImageUrl="<% $spurl:
~site/resources/companylogo.gif %>"/>

This renders as a proper image tag with the proper path in the browser.

However, in SP Designer, in design view, I get:

The expression prefix 'spurl' was not recognized.

I'm guessing that the SP Designer team just forgot to implement support
for this feature in its rendering engine, eh?

2) It appears that I can use this syntax in a standard HTML tag like

<link media="screen" href="<% $spurl:
~siteCollection/admin_siteCollection_CSS/mycstylesheet.css %>"
type="text/css" rel="stylesheet">

This produces a valid LINK tag with a valid path in the href when I
render it in the browser.

However, if I do this with an IMG tag:
<img src="<% $spurl: ~sitecollection/admin_siteUI_images/mylogo.gif %>"
id="mylogo" />

I get this error:

An error occurred during the processing of
/_catalogs/masterpage/mvpnew.master. Literal expressions like '<%
$spurl: ~ sitecollection/admin_siteUI_images/mylogo.gif %>' are not
allowed. Use <asp:Literal runat="server" Text="<%$spurl: ~
sitecollection/admin_siteUI_images/mylogo.gif %>" /> instead.

Why is it I can do this with a LINK tag but not an IMG tag? Or is there
some obvious syntax errors in my example above?