日期:2014-05-18  浏览次数:20417 次

请问怎么在一个ImageButton控件里面调用JS的函数?
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/js/edit.gif" />


<script language="javascript" type="text/javascript">
  function fnOpen(id,name) 
  {
  var returnTarget = window.showModalDialog("SubNatrue.aspx?id="+id+""+"&name="+escape(name)+"","", "dialogHeight=300px;dialogWidth=400px;center=yes;resizable=yes;help=no;");
  window.parent.location.reload(); 
  }
   
 </script>


我想在ImageButton中调用fnOpen方法

------解决方案--------------------
jq调用ImageButton2的点击事件执行fnOpen
------解决方案--------------------
客服端可以直接在 

<asp:ImageButton ID="ImageButton2" OnClientClick=“return fnOpen(id,name)” runat="server" ImageUrl="~/js/edit.gif" />

服务器当
Response.Write("<script>fnOpen(id,name)</script>") 

参数自己传进去就行了



------解决方案--------------------
<asp:ImageButton ImageUrl="" runat="server" OnClientClick="return fnOpe(id,name)"/>
------解决方案--------------------
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/js/edit.gif" OnClientClick="fnOpen(参数); return true;" />

如果不想造成postback return false;