Encouraging two-way communications

Share + Learn + Comment   Encouraging two-way communications

Discover our team’s valuable knowledge, experience, opinions, and advice. And let us know what you think!

Blog

Using the “Processing” Page in Your SharePoint 2010 Custom Modules

If you have ever worked with MOSS or SharePoint 2010 you remember this page:
long operation

It appears when you create new sites or run any other long-running operations.

Now, did you know that it’s very easy to have this page displayed during your own long-running operations? Not only that, it will redirect back to your code when it’s done with the execution.

Let’s say I have a UserControlWebpart in my SharePoint solution, and in my OnLoad method I call a couple of long-running operations and want the “Processing” page to show up. When completed, I want to come back to my page where the UserControlWebpart is. Here is all I need to wrap my custom long-running code with:

string comeBackUrl = this.ViewState["__REFERER__"].ToString();
using (SPLongOperation operation = new SPLongOperation(this.Page))
{
 operation.Begin();
 //….. your code here ….
 operation.End(comeBackUrl, Microsoft.SharePoint.Utilities.SPRedirectFlags.DoNotEncodeUrl, HttpContext.Current, null);
 }
That`s all that you need to do; SharePoint takes care of the rest. 
  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment
  1. Formatting options
       
     
     
     
     
       

Please Upgrade Your Browser

This site's design is only visible in a graphical browser that supports web standards, but its content is accessible to any browser or Internet device.