title: Calling server side event in asp.net from java script
body: <p>Surely will be marked as duplicate one but after tons of question and example i couldn't solve my problem. 
  <br><strong>What i want?</strong><br>
  Calling server side event handler in asp.net from client side java script it is not going on server side. I checked it by setting breakpoint, the page flicks but server side method is not called.
  <br>My click event on code behind is</p>
  
  <pre><code>  protected void btninsert_Click(object sender, EventArgs e)
    {
        // my code
    }
  </code></pre>
  
  <p>aspx file</p>
  
  <pre><code>   &lt;asp:Button ID="btninsert" runat="server" ValidationGroup="form" CssClass="btn"
        OnClientClick="DoPost()" Text="Save" /&gt;
  </code></pre>
  
  <p>Javascript method is </p>
  
  <pre><code>   function DoPost() {
          function DoPost() {
          var chk = document.getElementById('&lt;%= chkstatus.ClientID %&gt;');
          if (chk.checked)
              __doPostBack('&lt;%= btninsert.ClientID %&gt;', 'OnClick');
          return true;
          //return false;
      } 
      } 
  </code></pre>
  
  <p>I also tried this 
          <code>__doPostBack('btninsert', 'OnClick');</code> and <code>__doPostBack('btninsert', '');</code> and <code>$('btnSubmit').trigger('click');</code> with no success. </p>
  
  <p><strong>What am i doing wrong?</strong></p>
  
  <p><strong>Edit:</strong> If i uses <code>OnClick</code> event then it is going in the server side event irrespective of the <code>if condition</code> in the <code>DoPost</code> method.</p>