Monday, July 23, 2012

sharepoint event handler redirect page

/// An item is being added.
/// </SUMMARY>
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
// Any condition
if (properties.ListItem["Manager"] != SPContext.Current.Web.CurrentUser.LoginName)
{
// Set the status property to CancelWithRedirectUrl this tells the event handler to cancel the operation
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
// Get the application page generic with SPUtility
properties.RedirectUrl = SPUtility.GetGenericSetupPath("/MyProj/MyPage.aspx");
}
}

No comments:

Post a Comment