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.
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
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
Documentation
More Examples
- Popup Control for ASP.NET Web Forms - How to add buttons to a popup window
- Popup Control for ASP.NET Web Forms - How to show the popup control
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
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>
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;
}
}
}