1

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.

2

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')"/>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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