How might I add a JavaScript message box with a confirmation option in ASP.NET?
views:
81answers:
3
A:
Use Javascript's confirm() method.
if(confirm('Are you sure?')) {
// executed if the user clicks OK
}
Cody Caughlan
2009-11-11 05:21:39
+2
A:
Try using confirm :
<script>
var userWantsToContinue = confirm("do you want to continue ?");
</script>
Canavar
2009-11-11 05:22:08
A:
If you are needing to add a confirm dialog box when the user clicks a button (such as a Delete button), where clicking Cancel has the effect of canceling a postback, you can use the Button control's OnClientClick property like so:
OnClientClick="return confirm('This will permanently delete this item. Are you sure you want to do this?');"
For more information on working with client-side script in an ASP.NET WebForms application, check out: Client-Side Enhancements in ASP.NET.
Scott Mitchell
2010-03-04 20:41:59