I'd like using SPLongOperation in an event of a list (itemupdating). The problem is I don't have any argument to pass at the constructor of SPLongOperation (this.Page doesn't exist)

public override void ItemUpdating(SPItemEventProperties properties)
        using (SPLongOperation longOperation = new SPLongOperation())
            longOperation.LeadingHTML = "Enumerating ...";
            longOperation.TrailingHTML = "Please wait while the related items are checked.";

            //Start the long operation

            string redirectURL = SPContext.Current.Web.Url;


How can I use it properly and what is the correct argument?



You can't do that. I'll put it in a simple way - Even Receivers are not aware of HTTP Context, so you won't be able to get the instance of the page which 'triggered' (not directly of course) the event receiver. You best bet would be to override the New Item form and assign custom code to Save action, where you would start the long operation and then do the actual update. That way you would still have the HTTP context from where the SPLongOperation should be called. Or otherwise (just a suggestion), an Application page might be suitable in your case where you would call an SPListItem.Update().

  • Thanks for your reply but will you have a sample? I need to move files in the save action and set meta properties with value saved – user1898765 Aug 7 '15 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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