title: Fire AsyncFileUpload control through a Button
body: <p>I want to fire the AsnyncFileUpload control through another control in the page.</p>
  
  <p>I have used AsyncfileUpload from ASP.NET AJAX toolkit and hidden it through JQuery. And places a button next to it. When even i click this button and select a file i want to fire the AsycnFileUpload and upload files.</p>
  
  <p>I have written most of the code but i get an Javascript error when i select a file. </p>
  
  <hr>
  
  <p>(ERROR: Access Denied; </p>
  
  <p>PLACE: <code>setTimeout(function () {
                          mainForm.submit(); //Error here;
                          uploader._waitTimer = setTimeout(function () { uploader._wait() }, 100);
                      }, 0);</code></p>
  
  <hr>
  
  <pre><code>&lt;asp:Button ID="btnFileUpload" runat="server" Text="Add" onclientclick="FileUploadClick(); return false;"/&gt;
  &lt;ajaxToolkit:AsyncFileUpload  runat="server" ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern" UploadingBackColor="#CCFFFF"/&gt;
  </code></pre>
  
  <p>And this is my Javascript (I saw the markup generated by the control and got the File input
  type by appending "_ct102")</p>
  
  <pre><code>function FileUploadClick() {
              var fileUploadControl = document.getElementById('&lt;%= AsyncFileUpload1.ClientID %&gt;' + '_ctl02')
              fileUploadControl.click();
              //fileUploadControl.setActive();                
          }
  </code></pre>