Wednesday October 7th

Tuesday October 6th

Using JavaScript confirm() in ASP.NET control OnClientClick property

Have you tried using JavaScript confirm() function in ASP.NET Button, LinkButton or ImageButton client onclick property?


Great tip; put this one in the bag.

You dont’ really need to use an if statement within the OnClientClick since confirm returns true or false. Here’s a slightly simpler solution:

<asp:LinkButton ID=”lbtnDelete” runat=”server” CommandName=’DeleteItem’ Text=’Delete’ OnClientClick=”return confirm(’Are you sure you want to\ndelete this item?’);”></asp:LinkButton>

color me old, but using "return confirm " has been around quite awhile. nothing to see here... move on.


I posted a comment to the blog post saying: "Why not return Confirm()?"

He deleted the comment...

Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network