I want to call a code behind method from JavaScript. Here is the scenario: the user will see messagebox in which he/she can select Yes or No. If user selects Yes from the messagebox i want to call the Delete method in code behind else i want to call the Insert method. here is JS:
<script type="text/javascript" language="javascript">
function Func() {
var result = confirm('Are you sure you want to delete?');
if (result) {
//click ok button
//Call the Delete Method
}
else {
//click cancel button
//Call the Insert method
}
}
</script>
here is how my code-behind look like:
protected void Delete()
{
//delete code here
}
protected void Insert()
{
//insert code here
}
ListVieworGridView) that provides its own Delete button fully wired up, you can hook in a validation javascript. Otherwise, you're tasked with writing up the entire end-to-end client->server conversation yourself.