我写了这段代码,运行说我少了")" <asp:Image ID="Image1" runat="server" Height="30px" Width="31px" onclick='openTable("<%# CreateID(Eval("CustomerID"))"%>,this);'/>
我打开源代码发现:<img id="GridView1_ctl03_Image1" onclick="openTable(&quot;&lt;%# CreateID(Eval(&quot;CustomerID&quot;))&quot;%>,this);" 
应该怎么解决~~
src="" style="height:30px;width:31px;border-width:0px;" />

解决方案 »

  1.   

    改成这样:
    <asp:Image ID="Image1" runat="server" Height="30px" Width="31px" onclick='openTable("<%# CreateID(Eval("CustomerID")"%>,this);'/>多了一个)
      

  2.   

    怎么可能那openTable的括号是对应后面的那个啊~括号没少~主要是转义了~
    本来是这样的onclick='openTable("<%# CreateID(Eval("CustomerID"))"%>,this);'/>
    运行变成这样了
    <img id="GridView1_ctl03_Image1" onclick="openTable(&quot;&lt;%# CreateID(Eval(&quot;CustomerID&quot;))&quot;%>,this);" 
      

  3.   

    onclick="openTable('<%# CreateID(Eval("CustomerID"))'%>,this);"引号互换
      

  4.   

    onclick='openTable("<%# CreateID(Eval("CustomerID"))%>",this);'/>
      

  5.   

    onclick='openTable(<%# CreateID(Eval("CustomerID"))%>,this);'/>
      

  6.   

    image本身没有onclick事件
    你在page_load中添加
    Image1.Attribute.Add("onclick","openTable('<%# CreateID(Eval("CustomerID"))'%>,this);")
    openTable是js才可以这么写
      

  7.   

    怎么一定要用image呢?不是有imagebotton吗?用这个,直接在后台click事件中编码不是更好吗?
      

  8.   

    我要用客户端的啊`chenzhifeng(晓峰)的那么没用~~sqshine()的方法~我在试把他的代码贴过来直接就有问题说少了";",我已经给标点符号搞晕了~麻烦各位在看看啊~
    我是这样写的(我是在GridView中放个摸版列~里面放个image)
    所以我的事件是写在RowDataBound里
       (e.Row.FindControl("Image1") as Image).Attributes.Add("onclick","openTable('<%# CreateID('"+Eval("CustomerID")+"')%>',this);");
    我现在的报错未将对象引用到实例~~