Adding Windows

  • 3 minutes to read

You can manually add popup windows to the ASPxPopupControl control using one of the following methods.

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

ASPxPopupControl control is also capable of being bound to a data source. In this case, the control will automatically create a PopupWindow object for each record in the data source.

ASPxPopupControl Designer

To invoke the designer, use one of the following approaches.

  • Smart Tag command

    Open the smart tag of your ASPxPopupControl and click the Designer command.

    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 the Designer command.

    ASPxPopupControl_Designer_Ivoking_Properties

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

ASPxPopupControl_Designer_Windows

Adding Windows at Runtime

To add new popup windows at runtime, use one of the following methods of the ASPxPopupControl.Windows collection.

  • The PopupWindowCollection.Add method with several overloads. It creates a new PopupWindow object allowing you to specify several of its settings (depending on the chosen overload) and adds this object to the ASPxPopupControl.Windows collection. This method also returns the newly created object allowing you to perform any operation with it.

    protected void Popup_Init(object sender, EventArgs e) {
            // Adding a new window with specified settings and immediately make it shown during the 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 object to be passed as a parameter.

    protected void Popup_Init(object sender, EventArgs e) {
            // Creating 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
                });
    
            // Adding the first window from the newly created window list to the collection
            Popup.Windows.Add(windowList[0]);
    
            // Adding the first two windows from the list to the collection
            Popup.Windows.Add(windowList[0], windowList[1]);
    
            // Adding the list to the collection entirely
            Popup.Windows.AddRange(windowList);
        }
    

Modifying the Markup

To add windows manually in the markup, use the Windows markup section. The dx:PopupWindow tag represents a separate PopupWindow object. A simple code example is given 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>