Quantcast
Channel: SharePoint 2010 - General Discussions and Questions forum
Viewing all articles
Browse latest Browse all 17574

Event receiver

$
0
0

i have some doubts in event receivers.

when i do Itemadding or Itemadded, i frame like..

SPList oList = oWeb.Lists["Test"];
SPWeb.AllowUnsafeUpdates = true ;
 SPListItem oSPListItem = oList.Items.Add();
 oSPListItem["Title"] = "Hello SharePoint";
oSPListItem.Update();
oList.Update();
SPWeb.AllowUnsafeUpdates = false;

========================================================

when i do Itemupdating or Itemupdated..

SPWeb.AllowUnsafeUpdates = true ;
//i disable the event firing
oSPListItem.Update();
//i enable it again
oList.Update();
SPWeb.AllowUnsafeUpdates = false;

========================================================

when i do Itemdeleting or Itemdeleted..

SPWeb.AllowUnsafeUpdates = true ;
oSPListItem.Delete();
oList.Update();
SPWeb.AllowUnsafeUpdates = false;

========================================================

My doubts are
1) after updating an item , i am always updating the list oList.Update();
   Is it ok?
2) and while doing changes, which affects the content DB i am using SPWeb.AllowUnsafeUpdates = true ;
   Is it ok?
3)when i work on updating or updated event, i always disable the event before oSPListItem.Update();
   Is it ok?
4)when i delete an item, i am not updating the item, but i am updating the list
   Is it ok?


Viewing all articles
Browse latest Browse all 17574

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>