Showing posts with label Server. Show all posts
Showing posts with label Server. Show all posts

Monday, February 6, 2012

How to call code behind server method from a client side javascript

In this post we will see how to call a server side function from JavaScript.
 

HTML::
<div style="visibility: hidden">
<asp:Button ID="mybtn" runat="Server" onclick="mybtn_Click" />
</div>

Java Script::
var hiddenMyBtn = document.getElementById('<%= mybtn.ClientID %>');
hiddenMyBtn.click();

Server side code::
protected void mybtn_Click(object sender, EventArgs e)
{
//Do your stuff
}


Hope this helps...


Popular Posts