|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SharepointLabs.com Blog on MOSS - WSS 3.0 sharing experience, technology, news, views and more > Posts > Not able to get Current Context in Event Handler: Solution is here
|
2/20/2009To solve problem you need to create httpcontext constructor explicitly like below code
public class MyEventHandler: SPItemEventReceiver { HttpContext current; public MyEventHandler() { current = HttpContext.Current; }
public override void ItemAdding(SPItemEventProperties properties) {
//perform validation if required.
// get the list which item to be added SPSite objsite = new SPSite (properties.SiteId); SPWeb objweb = objsite.OpenWeb (properties.RelativeWebUrl); SPList objlist = objweb.Lists[properties.ListId];
//use this method to disable reoccurence of events.
DisableEventFiring(); SPListItem itemToAdd = objlist.Items.Add();
//add item to list
itemToAdd.Update(); EnableEventFiring();
// provision sub site and perform required action
//redirect it to your new destination like newly provisioned sub site or any other page you want.
SPUtility.Redirect(strNewresiractionUrl, SPRedirectFlags.Trusted,current);
}
Posted by Vaibhav Jain (Success is always one step ahead) |
|
|
|
|
|
|
|
|
|
 |
 |
 |
 |
|