title: Call C# method from javascript function
body: <p>I need to call the c# method from javascript. I need the method to be called only when the javascript button is clicked i.e (btnclick()). But Login method gets executed before the onclick of button.</p>
  
  <p>aspx file</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      function  btnclick()
      {
      &lt;%=Login() %&gt;;     //calling the c# method
      };
      $(document).ready(function ()
      {
  
          $(".username").focus(function () {
              $(".user-icon").css("left", "-48px");
          });
      &lt;/script&gt;
      &lt;body&gt;
      //contains other elements like username and password text boxes
      &lt;input type="submit" id="submit" name="submit" value="Login" class="button" onclick="btnclick()"/&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>aspx.cs file</p>
  
  <p>The following c# method have to be called from javascript</p>
  
  <pre><code> protected void Login()
  {
  //contains method for authentication
  }
  </code></pre>
  
  <p>Is there any other way to call c# method from javascript.</p>