GridView中使用如下button OnClientClick代码会出现解析错误

GridView中使用如下代码会出现解析错误:

<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")) %>' 

注:Title,Message为数据源中要帮定的列名

posted @ 2015-11-02 14:05  卡西法儿  阅读(253)  评论(1编辑  收藏  举报