PerformClick of Button不起作用 [英] PerformClick of Button not work

查看:63
本文介绍了PerformClick of Button不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我必须在运行时通过代码触发按钮的click事件.
我无法直接使用btn_click事件,因为在我要触发事件的地方无法访问它.

所以我尝试了PerformClick方法.
它在第一次使用时有效,但在第二次通话时我不做任何事情.
我想我应该在两次调用PerformClick之间做一些事情.
有任何想法吗?

Hi,

I have to fire click event of button by code at runtime.
I cannot drectly use btn_click event because it is not accessible where I want to fire event.

So I try PerformClick method.
it works at first time but I doesbt do anything at second call.
I guess I should do something between two call of PerformClick.
Have any idea?

推荐答案



您可以创建点击事件,例如,

Hi,

you can create click event like,

btn_Click += new ButtonClick(callingFunctionName);



希望对您有帮助,

谢谢
-amit.



hope this will help you,

thanks
-amit.


<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
    <title>Untitled Page</title>
    <script type="text/javascript">
    function clk()
    {
    document.getElementById('Button1').click();
    }
    </script>
       </head>
<body onload="clk();">
<div>
    <form id="form1" runat="server">

    <div>
        <asp:Button ID="Button1" runat="server" Text="Choose file.."

            onclick="Button1_Click"  />
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>

    </form>
    </div>

</body>
</html>



在上面的代码中,我调用了一个Java脚本函数,该函数在页面加载期间执行Asp按钮的click事件.

我希望这可以帮助您...



In the Above code i have called a java script function which perform click event of Asp button during page load.

I hope this may help u...


我敢打赌,如果您不时停止使用调试器,则可以自行判断发生的情况.
I bet if you stopped to used the debugger once in a while, you could detremine what''s happening on your own.


这篇关于PerformClick of Button不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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