Example E499
Visible to All Users

Popup Control for ASP.NET Web Forms - How to show and hide a pop-up window on the server side

This example demonstrates how to change the Popup Control's visibility on the server. Use this approach to process data on the server before users open and/or after they close a pop-up window. Otherwise, we recommend that you open and hide the pop-up window on the client to reduce server round trips.

Change the visibility of a pop-up window on the server

Overview

Set the ASPxPopupControl's server-side ShowOnPageLoad property value to true to display the default popup window at the client. If the popup control has multiple popup windows, use a PopupWindow's server-side ShowOnPageLoad property to specify visibility of this window at the client.

In this example, the Popup Control has a single window that contains a textbox and the OK and Cancel buttons. The control updates its ShowOnPageLoad property value as follows:

  • Sets to true after you click the Edit… button on a form
  • Sets to false after you click the OK button on the pop-up window

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

PopupInputFormServerSide/Default.aspx
ASPx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PopupInputFormServerSide._Default" %> <%@ Register Assembly="DevExpress.Web.v24.2, Version=24.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dxpc" %> <%@ Register Assembly="DevExpress.Web.v24.2, Version=24.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dxe" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <dxe:ASPxTextBox ID="txtMain" runat="server" Width="170px" ClientInstanceName="txtMain" ClientEnabled="False" Text="test message"> </dxe:ASPxTextBox> <dxe:ASPxButton ID="btnShowPopup" runat="server" Text="Edit..." OnClick="btnShowPopup_Click"> </dxe:ASPxButton> <dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="popupControl" Height="83px" Modal="True" CloseAction="CloseButton" Width="207px" AllowDragging="True" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"> <ContentCollection> <dxpc:PopupControlContentControl runat="server"> Text:<dxe:ASPxTextBox ID="txtPopup" runat="server" Width="170px" ClientInstanceName="txtPopup"> </dxe:ASPxTextBox> <br/><br/> <table style="border:none"> <tr> <td> <dxe:ASPxButton ID="btnOK" runat="server" AutoPostBack="False" Text="OK" Width="80px" OnClick="btnOK_Click"> </dxe:ASPxButton> </td> <td> <dxe:ASPxButton ID="btnCancel" runat="server" AutoPostBack="False" ClientInstanceName="btnCancel" Text="Cancel" Width="80px"> <ClientSideEvents Click="function(s, e) { popupControl.Hide(); }" /> </dxe:ASPxButton> </td> </tr> </table> </dxpc:PopupControlContentControl> </ContentCollection> </dxpc:ASPxPopupControl> </div> </form> </body> </html>
PopupInputFormServerSide/Default.aspx.cs(vb)
C#
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace PopupInputFormServerSide { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnShowPopup_Click(object sender, EventArgs e) { txtPopup.Text = txtMain.Text; ASPxPopupControl1.ShowOnPageLoad = true; } protected void btnOK_Click(object sender, EventArgs e) { // Add your code here to process the pop-up window's data on the server txtMain.Text = txtPopup.Text; ASPxPopupControl1.ShowOnPageLoad = false; } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.