Below is the code to close a SharePoint popup window on button click or any event from code behind
// Close if dialog
HttpContext context = HttpContext.Current;
if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
{ context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
}
else
SPUtility.Redirect(SPContext.Current.Web.Url, SPRedirectFlags.UseSource, HttpContext.Current);
Source attribute is a Query string which holds the url of the source page from where the page is usually called .This is default behavior of SharePoint. We can use this to navigate when the popup is closed and redirect to same source page as shown above
Eg: http://webpalication:1111?Source=http:wwww.google.com
// Close if dialog
HttpContext context = HttpContext.Current;
if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
{ context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
}
else
SPUtility.Redirect(SPContext.Current.Web.Url, SPRedirectFlags.UseSource, HttpContext.Current);
Source attribute is a Query string which holds the url of the source page from where the page is usually called .This is default behavior of SharePoint. We can use this to navigate when the popup is closed and redirect to same source page as shown above
Eg: http://webpalication:1111?Source=http:wwww.google.com
No comments:
Post a Comment