现在的位置: 首页 > 综合 > 正文

在 OnClientClick 中使用eval添加参数

2012年11月25日 ⁄ 综合 ⁄ 共 845字 ⁄ 字号 评论关闭

在 OnClientClick 中使用eval添加参数

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
      OnClientClick='return confirm("Delete the datasource <%# Eval("Title") %>?");'
      Text="delete" />

可以使用另一种写法完成所要表达的意思:

OnClientClick='<%# Eval("Title","return confirm(\"Delete the datasource {0}?\")") %>'

 在一个服务器端控件中使用多个Eval

OnClientClick='<%# String.Format("return ConfirmWindow(\"{0}\",\"{1}\")", Eval("Title"), Eval("Message")) %>'

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
      OnClientClick='return confirm("Delete the datasource <%# Eval("Title") %>?");'
      Text="delete" />

可以使用另一种写法完成所要表达的意思:

OnClientClick='<%# Eval("Title","return confirm(\"Delete the datasource {0}?\")") %>'

 在一个服务器端控件中使用多个Eval

OnClientClick='<%# String.Format("return ConfirmWindow(\"{0}\",\"{1}\")", Eval("Title"), Eval("Message")) %>'

抱歉!评论已关闭.