zoukankan      html  css  js  c++  java
  • 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();

                    }

                }

            }

        } }  

  • 相关阅读:
    【NOIp复习】图论算法模板合集
    【NOI导刊】【归并排序求逆序对】最接近神的人
    【NOIp 2012】【线段树】借教室
    【NOIp复习】最近公共祖先LCA&区间最大最小RMQ
    【NOIp 2015】【二分答案】跳石头
    【NOIp 2015】【DFS】斗地主
    【vijos】【BFS+hash】毒药?解药?
    【NOIp模拟】【dp】俄罗斯方块
    【NOIp模拟】【二分图or并查集】GoToandPlay
    【vjios】【DFS】切蛋糕
  • 原文地址:https://www.cnblogs.com/hqbird/p/3785179.html
Copyright © 2011-2022 走看看