首页 > 其他 > 详细

Programmatically Disable Event Firing on List Item Update in SharePoint 2010

时间:2014-06-15 23:34:32      阅读:431      评论:0      收藏:0      [点我收藏+]

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

                }

            }

        }

    } }  

Programmatically Disable Event Firing on List Item Update in SharePoint 2010,布布扣,bubuko.com

Programmatically Disable Event Firing on List Item Update in SharePoint 2010

原文:http://www.cnblogs.com/hqbird/p/3785179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!