简体   繁体   English

GridView内部的OnClinetClick在启用属性验证之前触发

[英]OnClinetClick inside gridview fires before Enabled property validation

I have a gridview with a link button template field inside the gridview. 我有一个gridview与gridview内的链接按钮模板字段。 The enabled property has a validation that disables the button based on the value of status field. enabled属性具有一个验证,该验证会根据状态字段的值禁用按钮。 The linkbutton has an OnClientClick property which displays a confirmation box. 链接按钮具有一个OnClientClick属性,该属性显示一个确认框。 If the user confirms, the OnCommand event fires. 如果用户确认,则将触发OnCommand事件。

' OnCommand="lnkBtnDeleteItem_Command" ToolTip='Delete Item' Enabled='<%# (Eval("Status") + string.Empty).Equals("5") ? 'OnCommand =“ lnkBtnDeleteItem_Command” ToolTip ='删除项目'已启用='<%#(Eval(“ Status”)+ string.Empty).Equals(“ 5”)吗? false : true %>'> 假:真%>'>

The problem is the OnclientClick validation pops up even when the button is disabled - which is done by the Enabled property validation. 问题是,即使禁用了按钮,也会弹出OnclientClick验证-这是由Enabled属性验证完成的。 How do i make the Enabled property validation to fire before onclientClick? 如何使Enabled属性验证在onclientClick之前触发? or any other alternatives? 或其他替代方法?

Thanks. 谢谢。

You can pop onclick event using code: 您可以使用以下代码弹出onclick事件:

if (status == 5)
  lbtnDelete.Attributes.Add("onClick", "return !this.disabled;");
else
  lbtnDelete.Attributes.Add("onClick", "return confirm('Are you sure?');");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM