ASP.Net - Confirmation Dialog

It is important to ask the user to confirm whether they want to delete an item incase the delete button was pressed by accident.

This is very easy to do in ASP.Net with JavaScript.

JavaScript confirmation dialog

Just use the code below:

.aspx
function confirmDelete()
{
	return confirm("Are you sure?");
}
C# Code Behind
btnDelete.Attributes.Add("onclick","return confirmDelete()");

It’s that simple. Now you have a fancy new confirmation dialog.

comments on this post

Jul 7, 2009 - 01:07:46

I admire the time and effort you put into your blog. I wish I had the same drive :)