Skip to main content
 首页 » 编程设计

c#之如何使用 OnClick 按钮事件运行 javascript fn (asp.net)

2024年02月23日32lyj

我有一个输入按钮,点击它时我调用了一个 javascript 函数。但是我想向按钮添加图像所以我使用了图像按钮,但我无法从图像按钮调用 Javascript 函数。单击图像按钮时如何运行 javascript fn

<input id="send" type="button" value=" Preview on iPhone " onclick="javascript:preview()"> 
 
 
   <asp:ImageButton  OnClick="preview()"  ID="send" runat="server" ImageUrl="Styles/Images/preview_iphone.png" 
                                     OnMouseOut="this.src='Styles/Images/preview_iphone.png'" 
                                    OnMouseOver="this.src='Styles/Images/preview_iphone_over.png'" /> 

请您参考如下方法:

试试 OnClientClick="javascript:preview()",这是客户端点击。

from here