Wednesday, October 12, 2011

SharePoint 2010 dialog Close Using the Code Box


SharePoint 2010, a new feature added to a dialogue. With the help of this, the user remains on the same page and to access information without leaving the current page. So there are ways we can close the dialog box code in different ways. These are mainly used implementations of JavaScript and behind the code.



Javascript:

 Window.frameElement is a node, which keeps the current window. CommitPopup () method requires the pop-up and closes the side windows. Thus, simply by calling the above method, the dialog box closes automatically.

Code-Behind:
  1. HttpContext context = HttpContext.Current;  
  2. if (HttpContext.Current.Request.QueryString["IsDlg"] != null){  
  3. context.Response.Write("window.frameElement.commitPopup();");  
  4. context.Response.Flush();  
  5. context.Response.End();  
  6. }  


The framework of dialogue recognizes an additional parameter in the query named "IsDlg = 1", which says that to open the page in the dialog box. Therefore, in the underlying code only checks the query string parameters and if it exists, then calls the JavaScript method mentioned above, writing in the browser. So when does the dialog will close.

This is a very nice tip, which helps some custom implementations. Hope that helps.






SPONSORS:

No comments:

Post a Comment

Post a Comment