从图像按钮单击事件调用Javascript函数 [英] Calling a Javascript function from a image button click event

查看:97
本文介绍了从图像按钮单击事件调用Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试在asp图像按钮控件的OnClientclick事件上调用javascript函数(该函数会加载一个jquery对话框弹出窗口)?第一次出现(仅1秒钟),页面将刷新,弹出窗口消失:(

有人可以帮我吗?

Hi,

i''s trying to call a javascript function(which loads a jquery dialog popup) on the OnClientclick event of an asp image button control? for the first time it appears(just for 1 second) and the page will get refreshed and popup disappears :(

Can anybody please help me on this?

推荐答案


我针对您的问题测试了以下一种正确的解决方案:

只需在js函数后添加return false

Hi,
I tested the following one this right solution for ur problem:

just add return false after js function

<asp:ImageButton OnClientClick="test(); return false" runat ="server"   ImageUrl="~/images/bg-black.gif"/>



U可以在html图像中调用它,如下所示:
如果您没有任何其他服务器端事件
< img onclick ="urjsfunction();" src =".."/>
Hi,
U can call it in html image like below:
if u dont have any other server side event
< img onclick="urjsfunction();" src=".."/ >




用这个..


use this..
<asp:ImageButton ID="imagebutton" runat="server" OnClientClick="image();" />


问候,
shefeek


regards,
shefeek


这篇关于从图像按钮单击事件调用Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆