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

How to close a dialog

Hello,

I am looking for an example of how to add a close button to dialog box and have the dialog box close when the user clicks the close button.
Can find anything on Syncfusion's website.

Thanks,
Doug Matulis

1 Reply

ES Ezhil S Syncfusion Team April 4, 2014 09:56 AM UTC

 

Hi Doug Matulis,

 

 

Thanks for your interest in Syncfusion products.

 

                We suggest you to add a close button to the dialog box using Dictionary class of dialog box control. After that call the clientsideclose event in client side and write script for that event. By using the close property of dialog method we can achieve close action through javascript.

 

 

Please refer the following code snippet:

 

<code>

[in View]

<div id="myDialog" title="Syncfusion Dialog" style="visibility: hidden">

 

    This is the Syncfusion Dialog control with the 'x' icon. The dialog    window can be moved, resized and closed.

 

</div>

 

@{Dictionary<string, string> buttons = new Dictionary<string, string>();

  

             buttons.Add("Close", "CloseDialog"); }

 

@Html.Syncfusion().Dialog("myDialog").Width(200).Height(100).AutoOpen(true).ClientSideClose("CloseDialog").Buttons(buttons)

 

[Script]

<script type="text/javascript">

    function CloseDialog(event) {

 

        $("#myDialog").dialog("close");

 

    }

</script>

 

</code>

 

We have prepared a simple sample to showcase this behaviour and the sample can be downloaded from the following link:

Link: http://www.syncfusion.com/downloads/support/directtrac/general/DialogwithCloseButton530506377.zip

 

 

You can find the following reference link on Syncfusion’ s website

1.      http://help.syncfusion.com/ug/asp.net%20mvc/tools/documents/addingbuttonstothedi.htm

2.      http://help.syncfusion.com/ug/asp.net%20mvc/tools/documents/clientsideevents4.htm

3.      http://help.syncfusion.com/ug/asp.net%20mvc/tools/documents/clientsidemethods4.htm

 

 

 

Kindly try the attached sample and let us know if this helps.

 

Regards,

Ezhil.S


Loader.
Live Chat Icon For mobile
Up arrow icon