Showing posts with label OnClientClick. Show all posts
Showing posts with label OnClientClick. Show all posts

Thursday, 23 October 2008

Add a confirm popup in asp .net

To add a confirm popup when a button is clicked in asp .net do the following:

In the buttons OnClientClick add the following javascript:

if(confirm('Are you sure?'))
{
return true;
}else{
return false;
}

The confirm method returns a boolean.

The popup displays the message, an Ok button and a canel button.

If Ok is clicked return true allows the button to cause a post back.
Clicking cancel returns false cancel the submit action of the button.
Free Hit Counter