SharePoint Spin Wheel “Operation in Progress”

Using Custom programming within SharePoint always takes time to execute and create a issue with impatient client. Client always think that we have not done a good job with coding so it will take a long time. Some time if some long operation is going on like creation of site or something like that then 3rd person thinks like process is hang up.
So what we need to do is that do some indication screen like “In progress”.



And the exciting news is SharePoint is providing built in function for “Operation in Progress” spinning wheel and object is called as “SPLongOperation”.

You can use this object in various places like creating a custom SharePoint site, setting up properties, creating a Project in Different server, calling a web services, updating/adding multiple items in SharePoint…. Etc.

Check the following snippet which is used in webpart.


void Button1_Click(object sender, EventArgs e)
{
SPLongOperation longoperation = new SPLongOperation(this.Page)

longoperation.LeadingHTML = "Leading HTML shows here";
longoperation.TrailingHTML = "Trailing HTML will be displayed here";
longoperation.Begin();

// Code which will take time…

longoperation.End(strURL);
}

How it works?

SPLongOperation has LeadingHTML properties which Shows message in Bold and TrailingHTML property shoes second a little large message.
Begin () method starts spinning wheel at a time on the same page.
You can find in debug mode that after execution of that line wheel appear on the screen.
All the code execute under wheel until you call End() function.
The End() method will take URL as parameter and will redirect to your desired page.

Special thanks to Brian Caauwe for his post which guide me to solve my headache.
posted @ 2008-10-24 23:07  laputa'sky  阅读(310)  评论(0编辑  收藏  举报