0

after many checking about redirecting to page from event recievers I understood that my best option it to di it from itemadding event and not itemadded.

that does not means that I can neglect the itemadded event code that I had, so in item adding event I called a page which in it there is a SPLongRunningOperation, and there actually the itemadded event code it running.

after the code it finished I calls :

         operation.EndScript(window.frameElement.commitPopup());

to close the dialog (dialog that opened while adding new item to a list)

My problem is that after closing that dialog I want to redirect to another page , and no stay on my list... I tired many things nothing works for me....

Hope for guideness TIA

1 Answer 1

0

Try that code in your event receiver:

class CustomEventHandler : SPItemEventReceiver
{
    private HttpContext currentContext;

    public CustomEventHandler() : base()
    {
        if (HttpContext.Current != null)
        {
            currentContext = HttpContext.Current;
        }
    }

    public override void ItemAdded(SPItemEventProperties properties)
    {
        SPUtility.Redirect("{url}", SPRedirectFlags.Default, currentContext);
    }
}
1
  • I came across that solution, this is tempting enough to try but as I read ItemAdded is a synchronous event and there is a purpose why the context is null in it, and even if you get the context to be full it might not always work... but as a last resort I will use this. TIA
    – Ronen
    Commented May 1, 2013 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.