Skip to main content

How to: Add Windows

  • 2 minutes to read

You can use one of the following methods to manually add popup windows to ASPxPopupControl:

  • Use the ASPxPopupControl Designer.
  • Modify the ASPxPopupControl.Windows collection manually at runtime.
  • Insert the required popup windows directly in the Windows section of the ASPxPopupControl markup.

You can also bind the control to a data source. In this case, the control automatically creates a PopupWindow object for each record in the data source.

In the Designer

Use one of the following techniques to invoke the designer:

  • Smart Tag command

    Invoke the ASPxPopupControl smart tag menu and click Designer….

    ASPxPopupControl_Designer_Ivoking_SmartTag

  • Context Menu command

    Right-click the ASPxPopupControl and click Designer….

    ASPxPopupControl_Designer_Ivoking_ContextMenu

  • Properties Window command

    In the Properties window, click Designer….

    ASPxPopupControl_Designer_Ivoking_Properties

In the Windows section, you can click the Add button to add a new popup window and configure its settings in the Item Properties area.

ASPxPopupControl_Designer_Windows

At Runtime

Use one of the following methods of the ASPxPopupControl.Windows collection to add new popup windows at runtime:

  • The PopupWindowCollection.Add method - Creates a new object and adds this object to the ASPxPopupControl.Windows collection.

    protected void Popup_Init(object sender, EventArgs e) {
            // Adds a new window with specified settings and immediately displays it on page load.
            Popup.Windows.Add("My custom content", "MyWindow", "Header", "Footer").ShowOnPageLoad = true;
        }
    
  • The Collection<T>.Add and Collection<T>.AddRange methods inherited from the Collection<T> class. These methods require one or more previously created PopupWindow objects to be passed as a parameter.

    protected void Popup_Init(object sender, EventArgs e) {
            // Creates a list of new windows
            List<PopupWindow> windowList = new List<PopupWindow>();
            foreach (Customer customer in CustomersList)
                windowList.Add(new PopupWindow() {
                    HeaderText = customer.Name,
                    FooterText = customer.Country,
                    Text = customer.Details
                });
    
            // Adds the first window from the newly created window list to the collection
            Popup.Windows.Add(windowList[0]);
    
            // Adds the first two windows from the list to the collection
            Popup.Windows.Add(windowList[0], windowList[1]);
    
            // Adds the entire list to the collection
            Popup.Windows.AddRange(windowList);
        }
    

In Markup

You can add PopupWindow object instances in the Windows section of the markup. See the simple code example below.

<dx:ASPxPopupControl runat="server" ID="Popup">
    <Windows>
        <dx:PopupWindow Name="AndrewFuller" HeaderText="Andrew Fuller" FooterText="Tacoma, USA"></dx:PopupWindow>
        <dx:PopupWindow Name="JanetLeverling" HeaderText="Janet Leverling" FooterText="Kirkland, USA"></dx:PopupWindow>
        <dx:PopupWindow Name="MargaretPeacock" HeaderText="Margaret Peacock" FooterText="Seattle, USA"></dx:PopupWindow>
        <dx:PopupWindow Name="NancyDavolio" HeaderText="Nancy Davolio" FooterText="Redmond, USA"></dx:PopupWindow>
    </Windows>
</dx:ASPxPopupControl>