111,094
社区成员




LinkButton lb1 = (LinkButton)e.Row.FindControl("LinkButton1");
if (e.Row.Cells[].Text == "")
{
lb1.Enable = false;
}
else
{
lb1.OnClientClick = "OpenDiv('');return false;";
}
<asp:LinkButton ID="LinkDataDelete" runat="server" Text="返还确认"
PostBackUrl='<%# String.Format("~/Asp_Forms/frm_MachineTakeOut_Detail.aspx?Guid={0}&Opr={1}",Eval("Guid"),"C") %>'
onclick="LcmdDataDelete_Click" ></asp:LinkButton>
这是在GridView中的一个LinkButton,可以看到我的这个控件并没有onClientClick事件!!因为我把这个事件注册在后台!!
C# Code
((LinkButton)e.Row.FindControl("LinkDataDelete")).Attributes.Add("onclick", "javascript:return confirm('您是否对此设备进行返还确认?')");
也就是说后台判断条件,条件成立的就为LinkButton注册一个前台事件!!如果条件不成立就不注册!!这样的话就能避免你说的这个问题了!!