Export (0) Print
Expand All
Expand Minimize

Coding a Long-Running Operation Page in SharePoint Server 2007

SharePoint 2007

Summary: Learn how to write code to mimic the default long-running operations page (the "spinning wheel") in Microsoft Office SharePoint Server 2007 or Windows SharePoint Services 3.0.

Office Visual How To

Applies to: Microsoft Office SharePoint Server 2007, Windows SharePoint Services 3.0

David Mann, Mann Software

August 2009

Overview

The Long-Running Operation page is familiar to anyone who uses Microsoft Office SharePoint Server 2007. It is called many things (including the spinning gears page and the spinning wheel) but it all comes down to a consistent UI for times when SharePoint Server needs to be doing a lot of work but the user is sitting and waiting. The ability to mimic this default functionality can make your application fit in with the rest of SharePoint Server.

Code It

The code for a long-running operation is simple: whatever code you place between your calls to Begin and End constitutes the long-running operation.

using (SPLongOperation operation = new SPLongOperation(this.Page))
{
  operation.LeadingHTML = "Please wait while the operation runs";
  operation.TrailingHTML = "";
  operation.Begin();
  if (DoOperation())
    ProcessResults = "Operation Completed Successfully";
  else
    ProcessResults = "An error occurred and was handled.";
  operation.End("LongRunnngOperation/Results.aspx", 
        SPRedirectFlags.UseSource |
        SPRedirectFlags.RelativeToLayoutsPage, 
        this.Context, "result=" + 
        Server.UrlEncode(ProcessResults));
}
Read It

The heart of the long-running operation happens in between the .Begin statement and the .End statement. While any code you place in between these two statements is running, the user sees the long-running operation page. When your work is complete, the .End statement is responsible for redirecting the user to whichever page you need them to view next—for example, a results page, settings.aspx, or the next page in a wizard.

See It

Coding a Long-Running Operation Page

Watch the Video

Video Length: 00:07:56

File Size: 11.8 MB WMV

Explore It

Community Additions

ADD
Show:
© 2014 Microsoft