SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a custom SharePoint application page and now I want to open it from edit control block (item context menu). My XML won't compile because it is telling me that I have illegal characters in the Url. The & characters are causing this. But if I use & instead, I can compile and deploy but the URL is wrong. This is because the JavaScrit understands & characters, where Visual Studio won't let me through.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <CustomAction Id="SPTest.CustomMenuItem.ButtonClicked"
                Title="My custom menu"
                Description="Click to my custom menu.">
    <UrlAction Url="javascript:OpenPopUpPageWithTitle('~site/_layouts/SP/MyAppPage.aspx?ListId={ListId}&ItemId={ItemId}', RefreshOnDialogClose, 530, 300, 'My custom menu')"/>

How do I format the URL? I found the sample that I used for my code here.

share|improve this question
up vote 2 down vote accepted

Ok, I found the solution. In the URL parameter of the JavaScript function, instead of ~site, I should have used {SiteUrl}.

So the UrlAction node should be:

<UrlAction Url="javascript:OpenPopUpPageWithTitle(
                'My custom menu')"/>
share|improve this answer

Your Answer


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.