title: How to call code behind server method from a client side JavaScript function?
body: <p>I am having an JavaScript function for a HTML button click event in ASPX page. And a server Method in its code behind page. Now i want to call the server method from the JavaScript function with some parameters only when the HTML button is clicked by the user. </p>
  
  <p>Please don't change this scenario and also don't use any asp.net contols in the aspx page while replying. Because only HTML controls are allowed. Can anyone help me on this ?. Thanks in advance. Eagerly waiting for answers.</p>
  
  <p>Here is the code,</p>
  
  <p>Code in markup:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      function btnAccept_onclick() {        
          var name;            
          name = document.getElementById('txtName').value;
  
          // Call Server side method SetName() by passing this parameter 'name'
  &lt;/script&gt;
  
  &lt;input type="button" id="btnAccept" value="Accept" onclick="return btnAccept_onclick()" /&gt;
  </code></pre>
  
  <p>Code-behind:</p>
  
  <pre><code>public void SetName(string name)
  {
      // Code for some functionality    
  }
  </code></pre>