We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to trigger a client side event on closing a Dialog?

Platform: ASP.NET Web Forms |
Control: Dialog


You can perform actions when the Dialog is closed by using the ClientSideOnClose event, based on the dialog contents. The client-side events are handled by using JavaScript in the client end itself.



The Dialog triggers the ClientSideOnClose event when the Dialog control is closed programmatically or the “X” icon in the control is clicked to close the Dialog box window. That is, the event is triggered after closing the Dialog control. You can handle the client side functionalities by using the ClientSideOnClose event in the script side.

The following scenario updates the NumericTextBox value in the web page based on the value entered in the Dialog box by using the ClientSideOnClose event. Also a Button is displayed to reopen the dialog that is hidden on creation.

Refer to the following code example.


 <%--Button, span and NumericTextBox updated after the dialog close event--%>
<ej:Button ID="btnOpen" Type="Button" CssClass="e-btn" Text="Click to open dialog" ClientSideOnClick="btnclick" runat="server" ClientSideOnCreate="onButtonCreate"></ej:Button>
<br />
<span id="label"></span>
<br />
<ej:NumericTextBox runat="server" ID="NumValFromDialog"></ej:NumericTextBox> 
<ej:Dialog ID="Dialog1" Title="Sample" runat="server" ClientSideOnClose="UpdateData">
            <br />
            Your dialog contents here    
            <br />
            <ej:NumericTextBox runat="server" ID="num1"></ej:NumericTextBox>

Define the Dialog close event in the client side script to perform the required action.


<script type="text/javascript">
    function UpdateData() {
        var numObj = $("#<%=num1.ClientID%>").data("ejNumericTextbox");
        //set the value entered in dialog content to another numeric text box in the web page
        $("#<%=NumValFromDialog.ClientID%>").ejNumericTextbox({ value: numObj.getValue() });
        $("#label").text("Result action from dialog close event");
// Button click event to reopen the Dialog box
    function btnclick() {
        var dialogObj = $("#<%=Dialog1.ClientID%>").data("ejDialog");
    function onButtonCreate(e) {

The following screenshots illustrate the output for the above scenario.

Dialog with NumericTextBox

Figure 1: Click the close icon (X) with some value entered in the NumericTextBox


Figure 2: Close event is handled in client side script to update the value of NumericTextBox and a button to reopen the Dialog box

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile