我正在关注这篇文章:http ://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-document-sets-custom-ribbon-buttons-with-custom-code/comment-page-1#comment-35294在功能区按钮中获取事件。
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Hello_world"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon"
Sequence="5">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button
Id="Ribbon.ManageDocumentSet.MDS.Manage.Controls.CustomButton"
TemplateAlias="o1"
ToolTipDescription="Demonstrate a ribbon doing something cool"
ToolTipTitle="Download as Zip"
LabelText="Weeeee"
Alt="Weee"
Command="Ribbon.ManageDocumentSet.MDS.Manage.CustomButtonClick"
Sequence="20"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Ribbon.ManageDocumentSet.MDS.Manage.CustomButtonClick" CommandAction="javascript:__doPostBack('MyDelegateEvent', '');"/>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
此 xml 将功能区放在 Documents.Manage 选项卡中。
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
ControlClass="SharePointProject1.MyClass"
ControlAssembly="SharePointProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5b43d1a96c6223e"
Sequence="50" Id="AdditionalPageHead"/>
</Elements><Control
ControlClass="SharePointProject1.MyClass"
ControlAssembly="SharePointProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5b43d1a96c6223e"
Sequence="50" Id="AdditionalPageHead"/>
</Elements>
控制类xml...
最后是cs类:
namespace SharePointProject1
{
public class MyClass : WebControl
{
const string MYEVENT = "MyDelegateEvent";
protected override void OnLoad(EventArgs e)
{
this.EnsureChildControls();
base.OnLoad(e);
if (this.Page.Request["__EVENTTARGET"] == MYEVENT)
{
// custom code here
int itemId = Convert.ToInt32(this.Page.Request["__EVENTARGUMENT"]);
System.IO.TextWriter mywriterFired = new StreamWriter(@"C:\zzz_CodeBehindFileItemMenu.txt", true);
mywriterFired.WriteLine("Event Fired at:" + DateTime.Now.ToLongTimeString() + ": Item ID:" + itemId.ToString());
mywriterFired.Close();
}
}
}
}
我在汇编中添加了这段代码......但是 __doPostBack 事件从未触发......每个人都知道可能是什么原因吗?