几个月前,我根据这篇微软开发者网络的文章,编写了一个带有自定义“删除”LinkButton和客户端JavaScript确认的ASP.NET GridView。
这个链接发布于2007年4月。http://msdn.microsoft.com/en-us/library/bb428868.aspx
例如:asp:ButtonField 点击前的 Javascript
这段代码看起来像这样:
<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).
生成的代码类似于
<a onclick="return confirm(...);" href="javascript:__doPostBack( ... )">
由于“取消”将返回false,我期望href中的 __doPostBack事件不会触发。我是否意外更改了任何奇怪的ie设置?还有什么可能导致这种奇怪的行为?或者这是一个“请重新安装WinXP”的问题吗?