title: Calling C# code behind method using javascript without ajax
body: <p>I have 2 buttons in my asp.net File</p>
  
  <pre><code>&lt;asp:Button ID="BTN_Send_LA" runat="server" Text="Save" OnClientClick="ConfirmSendData()"&gt;&lt;/asp:Button&gt;
  //The button the client will click
  
  &lt;asp:Button ID="UploadButton" runat="server" Text="" OnClick="BTN_Send_LA_Click"/&gt;
  //Dummy Button for the JS .click()
  </code></pre>
  
  <p>And here is my Js part:</p>
  
  <pre><code>function ConfirmSendData() {
      var r = confirm("Êtes vous bien: " + document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").options[document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").selectedIndex].text + " sinon veuillez changer dans le champ spécifié 'Laveur'");
  
      if (r == true) {
  
          var clickButton = document.getElementById("&lt;%= UploadButton.ClientID %&gt;");
          clickButton.click();
  
          //$('UploadButton').trigger('click'); TEST 1
          //__doPostBack not working aswell
  
      }
  }
  </code></pre>
  
  <p>So here what i expect to be done:</p>
  
  <ol>
  <li>The client click the first button (Trigger the JS)    => Works</li>
  <li>R is true => Works</li>
  <li>The JS part trigger the Onclick of UploadButton => Don't Work</li>
  </ol>
  
  <p>I don't understand why this method doesn't work as it seems to be the general approach most other answers take on StackOverflow?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Ok, I've tried every solutions proposed below and now i have weird problems:</p>
  
  <p>When I click on the client button, 1 of the 3 following things happens randomly (route followed with the debugger) </p>
  
  <p>1: The button click do a blank postback (IsPostBack == true) 
     event OnClick="BTN_Send_LA_Click" not fired </p>
  
  <p>2: The button click do a blank postback (IsPostBack == false) 
     event OnClick="BTN_Send_LA_Click" not fired </p>
  
  <p>3: The button fire the event OnClick="BTN_Send_LA_Click" of the dummy button properly.</p>
  
  <p>I don't understand why. When i click directly on the dummy button, everything works fine</p>
  
  <p><strong>Everytime I do a CTRL+F5, the first time I click the client button will work 100% (event fired)</strong></p>
  
  <p>something else: in my event BTN_Send_LA_Click(), I change the background color of multiple controls (lightgreen)</p>
  
  <p>1: If I click on the dummy button => the background color of the controls are changed</p>
  
  <p>2: If I click on the client button and even if the BTN_Send_LA_Click() is fired, the background color doesn't change.</p>
  
  <p>Why ? I'm totally lost on this one</p>
  
  <p>Updated code:</p>
  
  <pre><code>        function ConfirmSendData()
       {
              /*
              var dd = document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;");
              var txt = dd.options[dd.selectedIndex].text;
              var r = confirm("Êtes vous bien: " + txt + " sinon veuillez changer dans le champ spécifié 'Laveur'"); */
  
              var r = confirm("Êtes vous bien: " + document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").options[document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").selectedIndex].text + " sinon veuillez changer dans le champ spécifié 'Laveur'");
  
              if (r == true) {
                  //$("#&lt;%=UploadButton.ClientID%&gt;").click();
  
                  var clickButton = document.getElementById("&lt;%= UploadButton.ClientID %&gt;");
                  clickButton.click();
  
              }
              return false;  
      }
  </code></pre>