I’m using this code sample that came from jquery-ui website to show the dialog form.
How can I add functionality to the “OK” button. I want this button to invoke a javascript function “PageValidation”, and if it returned true, then call a C# function that will save the data in the db, and then close the modal form. If “PageValidation returned false then do nothing and don’t close the modal form.
This is the code:
$('#dialog').dialog({
autoOpen: false,
width: 600,
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
Thanks.
You can add your function in the “OK” function like this:
then, write the body of MyFunc() , like this:
and finally write the body of AjaxCSharpCall() to send an ajax request to a page, in which you can do your C# function. something like this: