我之后的下一个项目:http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-context-menu-item-with-custom-codedoPostBack没有发射
Elements.xml的
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="SPTest.CustomMenuItem.ButtonClicked"
RegistrationType="FileType"
RegistrationId="dtsx"
Location="EditControlBlock"
ImageUrl="/_layouts/IMAGES/DOCLINK.GIF"
Sequence="600"
Title="Execute Package"
Description="Executed Selected Package"
ControlAssembly="SPTest.CustomMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=beb14bc625e99e7f"
ControlClass="SPTest.CustomMenuItem.CustomItemAction"
>
<UrlAction Url="javascript:__doPostBack('SPTest.CustomMenuItem.CustomItemAction', {ItemId});" />
</CustomAction>
</Elements>
PACKAGE.TEMPLATE.XML
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/">
<Assemblies>
<Assembly Location="SPTest.CustomMenuItem.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="SPTest.CustomMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=beb14bc625e99e7f"
Namespace="SPTest.CustomMenuItem" TypeName="*" Safe="True" SafeAgainstScript="False" />
</SafeControls>
</Assembly>
</Assemblies>
</Solution>
所以......在Web.config文件我们可以在SafeControl中找到我们的组件
CLASS TO EXECUTE
using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace SPTest.CustomMenuItem
{
public class CustomItemAction : SPLinkButton
{
protected override void OnLoad(EventArgs e)
{
this.EnsureChildControls();
base.OnLoad(e);
if (this.Page.Request["__EVENTTARGET"] == "SPTest.CustomMenuItem.ButtonClicked")
{
int itemId = Convert.ToInt32(this.Page.Request["__EVENTARGUMENT"]);
System.IO.TextWriter writer = new StreamWriter(@"C:\XXXXX\XXXXX\XXXXX\custommenuoutput.txt", true);
writer.WriteLine("Event Fired at:" + DateTime.Now.ToLongTimeString() + ": Item ID:" + itemId.ToString());
writer.Close();
}
}
}
}
如您所见,目标是执行在Sharepoint上分配的SSIS包。具有执行包选项的ECB菜单出现在所有具有dtsx类型的文件中。因此,当我点击这个底部时,这个事件不起作用......我不知道我必须做什么......任何帮助都将会得到满足。谢谢!!
我将我的代码替换为您的,没有任何反应...... SiteActions组中没有任何选项出现 – 2012-02-14 10:17:53
选项不应在SiteActions组中显示 - 它应该在那里但不可见。为了使它可见,你应该为它提供标题。选择自定义操作时,网页是否会刷新(是否真的发布)?如果是的话,尝试添加**保护覆盖无效OnInit(EventArgs e)**到CustomItemAction并在里面设置断点 - 如果页面刷新时没有触发断点,则表示CustomItemAction不是页面控制树,不能处理回发。 – 2012-02-15 06:13:52