繁体   English   中英

如何在事件接收器中捕获button_click事件

[英]how to catch a button_click event in event receiver

我在Visual Studio 2013中创建了一个webpart按钮,并将其部署在具有特定功能的sharepoint 2013中。 现在我只想知道是否可以在事件接收器中捕获Button_click的事件?

我想通过button_click来限制我的事件接收器方法之一,以便如果单击元素按钮,则不要在ItemAdded中执行任何操作。

在Web部件中单击按钮时,需要在网站上设置属性袋值。

使用下面的链接来设置属性袋的值。 http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/05/12/how-to-write-a-value-into-the-property-bag.aspx

在您的项目添加事件中,检查属性包的值,以验证按钮单击是否完成。

问候

Hiren Gondhiya

非常感谢Hiren,我是根据您发送给我的内容来解决此问题的

SPWeb web = SPContext.Current.Web;
                    web.AllowUnsafeUpdates = true;
                    web.AllProperties["ButtonClick"] = "ButtonHasBeenCliked";
                    web.IndexedPropertyKeys.Add("ButtonClick");
                    web.Update();
                    web.AllowUnsafeUpdates = false;

在事件接收器中,我只是像这样检查

 using (SPSite site = new SPSite(Url))
  {
    using (SPWeb web = site.OpenWeb())
    {
               if(web.AllProperties["ButtonClick"].Equals("ButtonHasBeenCliked"))
               {
                 // Do nothing
               }
     }
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM