SharePoint 2010 Cookbook: How to Open & Close a Popup Window Using the OpenPopUpPageWithTitle Method

Using JavaScript, there are a variety of different methods to open a URL in a popup dialog in SharePoint 2010 . In this article, we will talk about how to open a popup using one of these methods, OpenPopUpPageWithTitle, and how to refresh the page after returning from the popup.

 

Challenge:

How do I open a popup using the OpenPopUpPageWithTitle method, and refresh the page after returning from the popup?

 

Solution:

Open Popup

Below is the signature of the method: 

OpenPopUpPageWithTitle(url, callback, width, height, title);

While the method parameters are self-explanatory, internally, the OpenPopUpPageWithTitle method is calling SP.UI.ModalDialog.showModalDialog(options), where the options are the parameters passed to the method.

URL is the path to a custom application page.

Callback is a method called and, in essence, can be anything along the lines of display notification(SP.UI.Notify).

Width and Height represent the size (in pixels) of the popup. If you want a fixed height and width, and you use null, then size will be defined automatically.

Title is the title of the popup.

Below is a screen shot of my example:

Close Popup

In the custom application page, we need to close the popup whenever it has finished executing. Below is the code to close the dialog box:

window.frameElement.commitPopup();

 

Refresh the Page After Returning From the Popup

Once the user has made some changes and closed the popup by clicking the OK button, on return from the popup, the .aspx page should be reloaded. To do so, you should use following function:

OpenPopUpPageWithTitle(url, RefreshPage , width, height, title);

RefreshPage: Using this method, we define and refresh the underlying page when the dialog closes.

Please enjoy, and good luck!

 

See Also:

 

Note:

Please see the attachment for the source code and script of my example.

SharePoint

Applications

SharePoint apps are stand-alone applications that perform specific tasks on a SharePoint site. Apps can perform functions such as managing a discussion board or knowledge base, performing project management or time tracking tasks, or doing other workflow operations.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


SharePoint

Web Parts

Extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of Web Parts. Web Parts are the building blocks of pages on a SharePoint site that can be used to customize the user interface and content of a site page. 

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


Office 365

Cloud Parts

Cloud Parts are functional components that extend your SharePoint environment whether it’s hosted, on-premises, or part of Microsoft Office 365. More than mere ports of existing software to the cloud, our Cloud Parts have been built from the ground up to take advantage of the best that the cloud has to offer.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Cloud Parts Suite for O365/SP Onl.


Featured Services

SharePoint Health Check

A SharePoint Health Check will identify the causes of issues and risks associated with your specific environment, and is custom tailored to provide you with the best recommendations to optimize your SharePoint environment.

SQL Health Check

Document recommendations relating to performance, stability, availability, or a specific focus you request of your SQL Server database instances.

My SharePointXperts

The truth is that each SharePoint skill may not be a full time job for many organizations, and it is nearly impossible for one person to do everything you need – so augment your team with SharePointXperts; providing the skill sets you need when you need them!