Nov 1, 2011

SPLongOperation Class in SharePoint

 Hi All,

Recently  I worked with this class in one of my projects to show the user with useful message when a long operation/activity is taking place in the background..I thought to share with you...

Here is the sample to use this..a webpart with a button. On click of button I am calling this..

protected void btnLoad_Click(object sender, EventArgs e)
  using (SPLongOperation myOperation = new SPLongOperation(this.Page))
    //main bold text when action is in progress
    myOperation.LeadingHTML = "Hey..! Connection established to the database server"; 
    //small text when action is in progress
    myOperation.TrailingHTML = "Please wait during the data fetch"; 
    //start the operation
    //our long running action here
    System.Threading.Thread.Sleep(120000);//2 mins 
   //end of the operation and it redirects to home page after end of the operation

Here is the result of this..

Happy Reading..!

No comments:

Post a Comment