You can use one Popup Control across all pages of your application to improve performance. This example demonstrates how to create a popup control on the master page and invoke it from multiple pages. The pop-up window's content depends on the page that shows this window.
In this example, the page WebForm1 populates the pop-up window with content during control initialization. The page WebForm2 specifies the window's content once the control sends a callback to the server. Use menu items Init approach and Callback approach to switch between these pages. Click the Show Popup button to show the pop-up window.
Follow the steps below to use one pop-up across multiple pages:
-
Place an empty popup control in the root master page.
-
Select the event that will generate pop-up window content:
- The
Init
event allows you to create pop-up window content at runtime during popup control initialization. - The WindowCallback event allows you to dynamically create pop-up window content once the window sends a callback.
The code snippet below assigns a handler to the
Init
event:<dx:ASPxPopupControl ID="popupControl" runat="server" ClientInstanceName="popup" OnInit="popupControl_Init" />
- The
-
Create a delegate for the event you selected in the previous step:
public event EventHandler PopupInit; protected void popupControl_Init(object sender, EventArgs e) { if (PopupInit != null) PopupInit(sender, e); }
-
Specify the master page's type name in all pages where you want to display pop-up windows:
<%@ MasterType TypeName="T501713.Root" %>
-
In these pages, call the event delegate and populate the pop-up window with content:
protected void Page_PreInit(object sender, EventArgs e) { Master.PopupInit += Master_PopupInit; } private void Master_PopupInit(object sender, EventArgs e) { // Populate the pop-up window with page-specific content }
-
Use the popup control's client instance name to show the pop-up window:
function button1_Click(s, e) { popup.Show(); }
- Root.Master (VB: Root.Master)
- Root.Master.cs (VB: Root.Master.vb)
- WebForm1.aspx (VB: WebForm1.aspx)
- WebForm1.aspx.cs (VB: WebForm1.aspx.vb)
- WebForm2.aspx (VB: WebForm2.aspx)
- WebForm2.aspx.cs (VB: WebForm2.aspx.vb)
- How to customize a pop-up window's content and layout
- How to create ASP.NET Web Forms controls dynamically
(you will be redirected to DevExpress.com to submit your response)