ASP.NET GridView "Client-Side Confirmation when Deleting" stopped working on ie - how come?

Posted by tarnold on Stack Overflow See other posts from Stack Overflow or by tarnold
Published on 2008-12-04T13:08:52Z Indexed on 2010/05/17 0:50 UTC
Read the original article Hit count: 237

Filed under:
|

A few months ago, I have programmed an ASP.NET GridView with a custom "Delete" LinkButton and Client-Side JavaScript Confirmation according to this msdn article:

http://msdn.microsoft.com/en-us/library/bb428868.aspx (published in April 2007)

or e.g. http://stackoverflow.com/questions/218733/javascript-before-aspbuttonfield-click

The code looks like this:

<ItemTemplate>
  <asp:LinkButton ID="deleteLinkButton" runat="server" 
    Text="Delete"
    OnCommand="deleteLinkButtonButton_Command"   
    CommandName='<%# Eval("id") %>'
    OnClientClick='<%# Eval("id", "return confirm(\"Delete Id {0}?\")") %>'
  />
</ItemTemplate>

Surprisingly, "Cancel" doesn't work no more with my ie (Version: 6.0.2900.2180.xpsp_sp2_qfe.080814-1242) - it always deletes the row. With Opera (Version 9.62) it still works as expeced and described in the msdn article. More surprisingly, on a fellow worker's machine with the same ie version, it still works ("Cancel" will not delete the row).

The generated code looks like

<a onclick="return confirm(...);" href="javascript:__doPostBack('...')">

As confirm(...) returns false on "Cancel", I expect the __doPostBack event in the href not to be fired. Are there any strange ie settings I accidentally might have changed? What else could be the cause of this weird behaviour? Or is this a "please reinstall WinXP" issue?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview