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();

                    }

                }

            }

        } }  

  • 相关阅读:
    .Net 更容易的使用配置文件 SuperConfig
    .Net 5分钟搞定网页实时监控
    记一次sql server 性能调优,查询从20秒至2秒
    [asp.net mvc 奇淫巧技] 05
    [asp.net mvc 奇淫巧技] 04
    [asp.net mvc 奇淫巧技] 03
    [asp.net mvc 奇淫巧技] 02
    ECharts 实现人民的名义关系图谱 代码开源
    C# 快速高效率复制对象另一种方式 表达式树
    Asp.net SignalR 应用并实现群聊功能 开源代码
  • 原文地址:https://www.cnblogs.com/hqbird/p/3785179.html
Copyright © 2011-2022 走看看