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

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="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="SPTest.CustomMenuItem.ButtonClicked"
                RegistrationType="ContentType"
                RegistrationId="0x0101"
                Location="EditControlBlock"
                ImageUrl="/_layouts/IMAGES/workflows.gif"
                Sequence="600"
                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')"/>
  </CustomAction>
</Elements>

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

share|improve this question

1 Answer 1

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(
                '{SiteUrl}/_layouts/SP/MyAppPage.aspx?ListId={ListId}&ItemId={ItemId}', 
                RefreshOnDialogClose, 
                530, 
                300, 
                'My custom menu')"/>
share|improve this answer

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.