Jevgeni Borozna's blog

SharePoint, ASP .NET

Long operations on a SharePoint 2007 page

Sometimes you would like to accomplish some task on a Page which takes more time than is set as “timeout” and you are seeing Request timed out in your browser.

This type of error is not so informative for end-user and is not beautiful for a complete solution.

SharePoint default solutions solving this kind of problems with “Operation in Progress” page:

image

SharePoint API proposes SPLongOperation named class to solve this problem the same way in your custom solutions.

MSDN documentation:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splongoperation.aspx

This class provides you two main methods: Begin() and End(); and to properties: LeadingHTML and TrailingHTML, which can be set to show custom text.

Between calling Begin and End methods you can complete long operations. Code example:

// "this" is a Page

using (SPLongOperation longOperation = new SPLongOperation(this))

{

    longOperation.LeadingHTML = "Your operation is in progress.";

    longOperation.TrailingHTML = "Your operation is currently ..";

 

    // start long operation

    longOperation.Begin();

 

    // do nothing 3 minutes

    Thread.Sleep(60000 * 3);

 

    // when operation will be finished

    // user will be redirected to this page

    longOperation.End("/_layouts/settings.aspx");

}

Comments

Twitter Trackbacks for Long operations on a SharePoint page - Jevgeni Borozna's blog [asp.net] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Long operations on a SharePoint page - Jevgeni Borozna's blog         [asp.net]        on Topsy.com

# January 21, 2010 12:16 PM

Twitter Mirror said:

Long operations on a SharePoint page http://weblogs. asp.net /jevgeni/archive/2010/01/21/long-operations

# January 21, 2010 12:26 PM

Links (1/21/2010) « Steve Pietrek-Everything SharePoint/Silverlight said:

Pingback from  Links (1/21/2010) « Steve Pietrek-Everything SharePoint/Silverlight

# January 21, 2010 8:10 PM

luxus escort zurich said:

Don't stop posting such articles. I like to read blogs like this. By the way add some pics :)

# September 2, 2010 5:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)