add javascript confirm to asp.net button

 

 

 

 

Adding JavaScript to ASP.NET Button onclick client event declaratively : With Button, LinkButton and ImageButton controls, OnClick attribute corresponds to server side click event. Adding JavaScript to ASP.NET Button onclick client event declaratively : With Button, LinkButton and ImageButton controls, OnClick attribute corresponds to server side click event. Tagged: asp.net, javascript, sweetalert, sweetalert2.Instead of creating a hidden button, you can reuse btnDelete by setting a flag to indicate that the action was already confirmed. Adding JavaScript to ASP.NET Button onclick client event declaratively : With Button, LinkButton and ImageButton controls, OnClick attribute corresponds to server side click event. I working on an ASP.Net C application, I wanted to create a Button Control, when user click on the button, a JavaScript confirm popup, then get the Boolean value from the user (Yes/No) to perform further actions in the button onClick event. Its easier than you think to attach a little javascript confirm popup to a proper ASP.Net server side button. Thanks to the OnClientClick event handler we can write our javascript right in the line and when the user thinks better of what theyre doing and clicks cancel the POST Updated Javascript code.