Posts

Showing posts from September 29, 2013

SharePoint Close methods for SP Long Operations and Redirect Error Page

Example 1 : protected override void OnClick(EventArgs e) { try{ using (SPLongOperation longOp = new SPLongOperation(this.Page)) { longOp.LeadingHTML = "Long Operation Title"; longOp.TrailingHTML = "This may take few seconds."; longOp.Begin(); //-------------------------- //code for long running operation is here //--------------------- EndOperation(longOp); } } catch (ThreadAbortException) { /* Thrown when redirected */} catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } } protected void EndOperation(SPLongOperation operation) { HttpContext context = HttpContext.Current; if (context.Request.QueryString["IsDlg"] != null) { context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>"); context.Response.Flush(); context.Response.End(); } else { string url = SPContext.Curre