Thursday, May 15, 2014

Modal Popup- close sharepoint page and sharepoint popup page in code behind

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>");


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?


No comments:

Post a Comment