Skip to main content


Go Search

Boman.Biz > Posts > Changing the message during a Microsoft.SharePoint.SPLongOperation
Changing the message during a Microsoft.SharePoint.SPLongOperation

The SPLongOperation is undoubtedly a Good Thing® to let users know that something is happening during a long processing operation. I had cause to use one the other day, and thought that it would be great to be able to change the message during the processing to let the user know which part of the Long Operation it was up to.

For example:

Using objLongOp As New SPLongOperation(Me.Page)

objLongOp.LeadingHTML = "Leading HTML"

objLongOp.TrailingHTML = "Trailing HTML"






objLongOp.LeadingHTML = "New Leading HTML"

objLongOp.TrailingHTML = "New Trailing HTML"





End Using


Would result in this screen, for 6 seconds:

I wrote a wrapper class called SPLongOperationEx to make sure that in our example after the first 3 seconds the LeadingHTML and TrailingHTML text is updated with the new values. This way you can have much longer Long Operations and still keep the user happy J

3 seconds later ...

This is a fairly trivial programming exercise once you understand how the SPLongOperation class is manipulating the browser, but I thought I would package it up into a separate class for easy re-use to save people some time.

Download the SPLongOperationEx Class here. (VB.NET)

Thanks to my good friend Adrian Bear from i-PMO, here is the C# version with support for line breaks in the message:

Download the SPLongOperationEX Class here. (C#)



Hi, great idea but it´s not working in my environemnt WSS 3.0 SP2. The sptLeading element can not be found. Have you found the same error?
at 19/03/2010 12:20 AM

Use LongRunningOperationJob insted

Use LongRunningOperationJob to change the message during the processing to let the user know which part of the Long Operation it was up to.
at 21/01/2011 5:29 PM


Simple !! good job
at 22/09/2011 1:22 AM


Works great with Internet Explorer but does not work in Firefox. Any ideas?
at 23/12/2011 8:47 PM


at 1/11/2014 4:03 PM

at 15/11/2014 10:57 AM

Add Comment


Body *

From *

(not rendered on the page)

If you are commenting to add SPAM - what is your motivation? *