Close modal dialog when SPLongOperation Complete

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();
      //--------------------------
      //here code part
      //---------------------

      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.Current.Web.Url;
         longOp.End(url, SPRedirectFlags.CheckUrl, context, string.Empty);
      }
} } catch (ThreadAbortException) { /* Thrown when redirected */} catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } }

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell