Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a code behinds button click event using javascript

Is it possible to call a server side buttons click event using javascript or jquery If yes then how to do it

like image 936
vidyasagar85 Avatar asked Jan 04 '13 11:01

vidyasagar85


3 Answers

Lets say this is your html:

<input type="button" id="button" value="btn" />

In jquery, you invoke click of button as below:

$("#button").click();   //button is id

And in javascript:

document.getElementById("button").click();
like image 154
Ashwin Avatar answered Oct 20 '22 00:10

Ashwin


Yes, javascript can do that. I assume you are using ASP.Net

<asp:Button ID="button" runat="server" Text="Test" />

<script>
    document.getElementById("<%= button.ClientID %>").click();
</script>
like image 23
phnkha Avatar answered Oct 20 '22 00:10

phnkha


document.getElementById("Button1").click();
like image 38
Azzy Avatar answered Oct 20 '22 01:10

Azzy