Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

It seems you cannot use the ~site or ~siteCollection tokens in an Element.xml when you deploy as a Sandboxed Solution. Has anyone ever seen this behaviour?

Code snippet:

><sharepoint:SoapDataSource runat="server" SelectUrl="~site/blog/_vti_bin/lists.asmx" InsertUrl=""

The ~site token gets replaced by an empty string (i.e. disappears) instead of the site URL upon deployment. Why?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

The ~Site and ~SiteCollection tokens are part of the Publishing dll which is not allowed in the Sandbox. So they cannot be referenced from your code or aspx pages. However, the tokens can be used with the Elements.xml. I have used them in the following way:

<CustomAction Location="ScriptLink" ScriptSrc="~Site/SiteAssets/myScript.js"/>

share|improve this answer
    
I have the idea that the replacement only works in node attributes. In my case, I need the replacement inside the content of the AllUsersWebPart (inside a CDATA block), there it doesn't seem to be working. –  Jasper Feb 10 '12 at 10:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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