<div class="row">
<ej:Button ID="btnOpen" Type="Button" CssClass="e-btn" Text="Click to open dialog" ClientSideOnClick="btnclick" runat="server" ClientSideOnCreate="onButtonCreate"></ej:Button>
<ej:Dialog ID="Dialog1" Title="Sample" runat="server" ClientSideOnClose="ClearData">
<DialogContent>
<div>
<br />
Your dialog contents here
<br />
<ej:NumericTextBox runat="server" ID="num1"></ej:NumericTextBox>
<br />
<ej:Button runat="server" ID="button1" Text="OK"></ej:Button>
<ej:Button runat="server" ID="button2" Text="Cancel" ClientSideOnClick="ClearData"></ej:Button>
</div>
</DialogContent>
</ej:Dialog>
</div>
[Script]
<script type="text/javascript">
function ClearData() {
$("#<%=num1.ClientID%>").ejNumericTextbox({ value: null }); // Clears the value in numeric text box
var dialogObj = $("#<%=Dialog1.ClientID%>").data("ejDialog");
if (!dialogObj.isOpened())
$("#<%=btnOpen.ClientID%>").show(); // shows button to open the dialog after closed
}
function btnclick() {
var dialogObj = $("#<%=Dialog1.ClientID%>").data("ejDialog");
dialogObj.open();// opens the dialog and hides the button
$("#<%=btnOpen.ClientID%>").hide();
}
function onButtonCreate(e) {
$("#<%=btnOpen.ClientID%>").hide();
}
</script> </code>
For further references on events available in Dialog control refer the link below:
http://help.syncfusion.com/UG/JS_CR/ejDialog.html#Events
Sample prepared can be downloaded from the following link:
http://www.syncfusion.com/downloads/support/forum/118886/Dialog_f118886894316687.zip
Please let us know if you have any other queries.
Regards,
Ezhil S
We are unable to understand your query. As you have mentioned as .Net function does that means you want to clear the values using a server side function on closing the dialog? As per the initial query you have mentioned as clearing the values using button click event and do you want to call the same code behind function on closing the Dialog control? Please share us more details on how you are using the Dialog control and clearing the values using button click. So that we can provide you a solution.
Please let us know if you have any other queries.
Regards,
Ezhil S
Hi Paul,
Thanks for the update.
For your requested use case scenario, we suggest you to use manual ajax call & web method for callingserver side method on closing the dialog since we don’t have inbuilt server side event on closing the dialog. Kindly give a try with below code and let us know if you face any other issues.
<code>
[CS]
[System.Web.Services.WebMethod]
public static string CallIt(string one)
{
return "sample Content From The Server";
}
[ASPX]
<script type="text/javascript">
function onDialogClose(args) {
$.ajax({
type: "POST",
url: "Default.aspx/CallIt",
data: '{one:"SampleData" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(data) {
$("#data1").html(data.d);
}
</script>
</code>
Note: you can call the same method which was mapped in cancel event in dialog close too by changing the URL in Ajax post.
We have prepared thesample and attached it in a below:
http://www.syncfusion.com/downloads/support/forum/118886/Datepicker-655621615.zip
Please let us know if you have any other concerns .
Regards,
Muralishanakar S.
<script type="text/javascript"> function onDialogClose(args) { $.ajax({ type: "POST", url: "Dashboard.aspx/ClearForm", contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); } }); } function OnSuccess(data) { $("#data1").html("IT WORKED"); } </script> <div id="data1"></div>
<ej:Dialog ID="dlgAddCRMA" runat="server" Content="#masterForm" Visible="false" Title="Add New CRMA" ShowHeader="true" ClientSideOnClose="onDialogClose">
The Code Behind Method:
[WebMethod] private void ClearForm()