Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is the code behind code page
C#
public void  test()
      {
          txtOTP.Value = "OTP has expired Please resend OTP";

      }



this is the the jquery mobile button

HTML
<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]
Posted
Updated 13-Aug-14 21:54pm
v2
Comments
OriginalGriff 14-Aug-14 3:54am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
mrDivan 14-Aug-14 4:03am    
Sorry

Hi, have a look at the __doPostBack function.

You could do something like this:

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


ASP.NET
<!-- 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.
 
Share this answer
 
Just use:
$('#Button1').click();
 
Share this answer
 
use ajax..
eg:
JavaScript
$("#Button1").click(function()
{
 

$.ajax({
    url : "test",
    type: "POST",
   dataType: 'json'
    
    
});
 

});
 
Share this answer
 
Comments
mrDivan 14-Aug-14 4:28am    
Hi thank you for your response. I tried but the method doesn't get executed
NowYouSeeMe 14-Aug-14 5:09am    
are you using webform or mvc ?
mrDivan 14-Aug-14 8:57am    
webform
just use onserverclick to fire the event on the serverside
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900