0
delete.Attributes.Add("onclick", "return confirm('Are you sure to delete?');");

此代码运行良好,但在我的新项目中,即使您在警报窗口上单击取消,它也始终返回 true。

我知道我的项目之间的唯一区别是新项目是 4.5 .Net 框架,而其他项目是 4.0

使用 WebForms Asp.Net

有什么建议么?

这是代码:

protected void gvEnterprises_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { name = HttpUtility.HtmlDecode(e.Row.Cells[1].Text); var delete = (LinkButton)e.Row.Cells[0].Controls[0]; delete.Attributes.Add("onclick", "return confirm('Are you sure to delete [" + name + "]?');"); delete.Text = "Del"; delete.Style.Add("color", "#D00000"); } }
4

0 回答 0