title: Triggering an Ext.net button click with JavaScript
body: <p>I have an ext:button. I want to trigger it's OnClick event by JavaScript based on the condition of a confirm message. </p>
  
  <p>My Button</p>
  
  <pre><code>&lt;ext:Button ID="btnAddEsya" Text="text" runat="server" Icon="Add" &gt;
      &lt;DirectEvents&gt;
          &lt;Click OnEvent="btnAddEsya_Click" ViewStateMode="Enabled"&gt;
          &lt;/Click&gt;
      &lt;/DirectEvents&gt;
  &lt;/ext:Button&gt;
  </code></pre>
  
  <p>Code Behind (only relevant parts)</p>
  
  <pre><code>[DirectMethod]
      public void btnAddEsya_Click(object sender, EventArgs e)
      {
       if (/*Checking conditions here*/)
          {
              X.Msg.Confirm("Warning", "Save?", new JFunction { Fn = "SaveLine" }).Show();
          }
  
  }
  </code></pre>
  
  <p>Java Script</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
          var SaveLine = function (btn) {
              if (btn == 'yes') {
                  alert('TEST YES');
                  NewLine.click();
                  document.getElementById('btnAddEsya').click();
  
  
              }
              else if (btn == 'no')
              { alert('TEST NO'); }
          };
              &lt;/script&gt;
  </code></pre>
  
  <p>So far I tried this method, the __doPostBack('btnAddEsya','OnClick'); method and assigning the buttons to variables and calling them as variablename.click(). None of them worked.</p>
  
  <p>Can it be about ext.net buttons Click OnEvent ? </p>
  
  <p>Edit: </p>
  
  <p>Recently I tried this too, and it didn't work either. Also </p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
          btnAddEsya = document.getElementById('&lt;%= btnAddEsya.ClientID %&gt;');
          var SaveLine = function (btn) {
              if (btn == 'yes') {
                  alert('TEST YES');
                  btnAddEsya.click();
                  }
              else if (btn == 'no')
              { alert('TEST NO'); }
          };
              &lt;/script&gt;
  </code></pre>