Showing posts from January, 2015

Custom Event Receiver in SharePoint

What is Event Receiver in SharePoint? By creating event receivers, you can respond when a user interacts with SharePoint objects such as lists or list items.

Feature receivers provide developers with an opportunity to execute code as a feature goes through different stages. The following is the list of feature event receivers:

Allow unsafe update vs run with elevated privileges in sharepoint

What is allow unsafe update and run with elevated privileges in SharePoint 2010? What are the differences between allow unsafe update and RWEP.

 “AllowUnsafeUpdates is set to true when you are trying to update the database.
To GET the content from the content DB, we need to set the AllowUnsafeUpdates = true.
For reasons of security, Microsoft SharePoint does not allow you to make posts from a Web application to modify the content database unless you include security validation on the page.

SPList list= web.Lists["MyList"];
SPListItemCollection items= list.GetItems();
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in items)
     item["Title"] = "New Title";
web.AllowUnsafeUpdates = false;

Run with Elevated Privileges

Executes the specified method with Full Control rights even if the user does not otherwise have Full Control.


    using (SPSite site = new SPSite(web.Site.ID))