我做了一个自定义SharePoint应用程序页面,现在我想从编辑控制块(项目上下文菜单)打开它。我的XML不会编译,因为它告诉我我在Url中有非法字符。该 & 字符导致这种情况。但如果我用 & 相反,我可以编译和部署,但URL是错误的。这是因为JavaScrit了解 & 角色,Visual Studio不会让我通过的地方。

<?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>

如何格式化URL?我找到了我用于我的代码的示例 这里.

有帮助吗?

解决方案

好吧,我找到了解决方案。在JavaScript函数的URL参数中,而不是 ~site, ,我应该用 {SiteUrl}.

所以UrlAction节点应该是:

<UrlAction Url="javascript:OpenPopUpPageWithTitle(
                '{SiteUrl}/_layouts/SP/MyAppPage.aspx?ListId={ListId}&ItemId={ItemId}', 
                RefreshOnDialogClose, 
                530, 
                300, 
                'My custom menu')"/>
许可以下: CC-BY-SA归因
scroll top