• Programmatically Disable Event Firing on List Item Update in SharePoint 2010


    1. Microsoft.SharePoint.dll

    Create EventFiring.cs 1.Right-click on the project, select Add and click on New Item. 2.In the templates pane, select Class. 3.Enter the Name as EventFiring and then click OK. 4.Replace EventFiring.cs with the following code:   using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Microsoft.SharePoint;

    namespace DisableEventFiring

    {

       public classEventFiring : SPItemEventReceiver

        {

           public void DisableHandleEventFiring()

            {

               this.EventFiringEnabled =false;

            }

           public void EnableHandleEventFiring()

            {

               this.EventFiringEnabled =true;

            }

        } }

    Program.cs 1.Replace Program.cs with the following code:   using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Microsoft.SharePoint;

    namespace DisableEventFiring

    {

       class Program

        {

           static void Main(string[] args)

            {

               using (SPSite site = new SPSite("https://serverName/sites/Vijai/"))

                {

                    using (SPWeb web = site.OpenWeb())

                    {

                        SPList list = web.Lists.TryGetList("Custom");

                        SPListItem item = list.GetItemById(34);

                        item["Title"] ="Updated Successfully";

                        EventFiring eventFiring = newEventFiring();

                        eventFiring.DisableHandleEventFiring();

                        item.Update();

                        eventFiring.EnableHandleEventFiring();

                        Console.WriteLine("Updated Successfully");

                        Console.ReadLine();

                    }

                }

            }

        } }  

  • 相关阅读:
    实测好用的awvs批量添加任务脚本
    SQL注入漏洞
    CTF-WEB-信息泄露题目总结
    Awvs+nessus docker版本
    禅道12.4.2后台管理员权限Getshell复现
    子域名工具,使用必应搜索引擎
    i春秋第二届春秋欢乐赛-Web-Hello World
    百度杯CTF比赛 九月场-WEB-题目名称:SQL
    文件上传漏洞
    CVE-2019-17625漏洞复现(Rambox 0.6.9版本存储型XSS)
  • 原文地址:https://www.cnblogs.com/hqbird/p/3785179.html
Copyright © 2020-2023  润新知