Question

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.

Was it helpful?

Solution

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')"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top