我之後的下一個項目: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