如何从jquery执行asp.net.cs页面中的按钮单击 [英] How to execute button click in asp.net.cs page from jquery

查看:39
本文介绍了如何从jquery执行asp.net.cs页面中的按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码页背后的代码

  public   void  test()
{
txtOTP.Value = OTP已过期请重新发送OTP;

}







这是jquery移动按钮



 <  按钮    type   = 提交    id   =  Button1      class   =  ui-btn ui-shadow  > 重新发送<   / button  >  







我希望它在click1单击时触发测试方法ed



请帮帮我



SHOUTING删除 - OriginalGriff [/ edit]

解决方案

看看__doPostBack函数。



你可以这样做:



  //  创建一个按钮单击调用测试方法的事件处理程序 
protected void Button_Click( object sender,EventArgs e)
{
test();
}





 <! -  -    创建一个asp:按钮 - 设置它(服务器端)点击处理程序 - 然后隐藏它   - >   
< asp :按钮 id = 按钮 runat = server onclick = Button_Click text = 按钮 <温泉n class =code-attribute> style = display:none xmlns:asp = #unknown / >

<! - 设置按钮单击处理程序以调用__doPostBack - >
< 按钮 类型 = 提交 < span class =code-attribute> id = Button1 class = ui-btn ui-shadow onclick = __ doPostBack('Button',''); > 重新发送< / button >





有一篇很好的文章HERE - 你应该读一读。



希望它有帮助。


只需使用:

 


('#Button1')。点击();


this is the code behind code page

public void  test()
      {
          txtOTP.Value = "OTP has expired Please resend OTP";

      }




this is the the jquery mobile button

<button type="submit" id="Button1"  class="ui-btn ui-shadow">Resend</button>




I want it to trigger the test method when button1 is clicked

please help me

[edit]SHOUTING removed - OriginalGriff[/edit]

解决方案

Hi, have a look at the __doPostBack function.

You could do something like this:

//Create an button click event handler that calls your test method
protected void Button_Click(object sender, EventArgs e)
{
    test();
}



<!-- Create an asp:Button- set it's (server side) click handler - then hide it -->
<asp:button id="Button" runat="server" onclick="Button_Click" text="Button" style="display:none" xmlns:asp="#unknown" />

<!-- set up your buttons click handler to call __doPostBack -->
<button type="submit" id="Button1" class="ui-btn ui-shadow" onclick="__doPostBack( 'Button', '' );">Resend</button>



There is a nice article HERE - you should have a read at it.

Hope it helps.


Just use:


('#Button1').click();


这篇关于如何从jquery执行asp.net.cs页面中的按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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