title: AJAX AsynchFileUpload stop upload process
body: <p>ASP.net website using AJAX AsyncFileUpload</p>
  
  <p>Hello Experts,</p>
  
  <p>In my web page I have only two controls, one is a textbox for the user to enter a template name and the second one is an AJAX AsyncFileUpload.</p>
  
  <p>When the user clicks on the "Browse" button of my AsynchFileUpload control and selects a file, I'm validating the Textbox for "Empty field" using the "OnClientUploadStarted" event. <strong>If the textbox is empty, I want to stop the upload process of the AJAX Control.</strong></p>
  
  <p>After some research I found a link in this forum where an user implements <strong>sender._stopLoad()</strong> method inside the function that handles the "OnClientUploadStarted" event. After applying the same logic, the function stops the load process, but I'm getting the following alert box from the browser:</p>
  
  <p><strong>Unhandled Exception: Cannot call method 'split' of undefined</strong></p>
  
  <p>I have no split method being used in my code. This error appears when using _loadStop() method from the AJAX asynchfileupload. Here is the code that I'm using:</p>
  
  <p>JavaScript Function to handle event:</p>
  
  <pre><code>function FileUpload_BeforeUpload(sender, args) {
     if ($get('&lt;%=TemplateNameTextBox.ClientID%&gt;').value == "") {
         sender._stopLoad();
     }
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;asp:TableRow&gt;
     &lt;asp:TableCell&gt;Template Name:&lt;/asp:TableCell&gt;
     &lt;asp:TableCell&gt;
        &lt;asp:TextBox runat="server" ID="TemplateNameTextBox" Width="250px"&gt;&lt;/asp:TextBox&gt;
     &lt;/asp:TableCell&gt;
     &lt;asp:TableCell&gt;
         &lt;asp:AsyncFileUpload runat="server" ID="AsyncFileUpload1"      
                  OnClientUploadStarted="FileUpload_BeforeUpload"/&gt;  
     &lt;/asp:TableCell&gt;
  &lt;/asp:TableRow&gt;
  </code></pre>
  
  <p>I have tested my code in all main browsers (IE, Firefox and Chrome) and I get the same error message. Have you guys come across this issue? and if so, how did you fix it?</p>
  
  <p>Thanks for your help.</p>
  
  <p>YPC.</p>