0

I'm using a AjaxFilUpload from the Ajax Control toolkit in my webform. I want to check for file size and cancelUpload if it has exceeded a certain size. I've tried it in OnClientUploadStart & OnClientUploadComplete, but after doing so the file still shows Uploaded on the page.

Webform:

<div>
  <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="AjaxFileUpload1_UploadComplete" OnUploadStart="AjaxFileUpload1_UploadStart" 
  OnClientUploadCompleteAll="onUploadCompleteAll" OnClientUploadComplete="onUploadComplete" OnClientUploadStart="onUploadStart" />
</div>

Javascript:

function onUploadStart(sender, args) {
     sender.cancelUpload();
}

function onUploadComplete(sender, args) {
     sender.cancelUpload();
}

Web.config:

<handlers>
  <add name="AjaxFileUploadHandler" verb="*"
    path="AjaxFileUploadHandler.axd"
    type="AjaxControlToolkit.AjaxFileUploadHandler, 
      AjaxControlToolkit"/>
</handlers>

How am I to cancel an upload?

KFP
  • 699
  • 3
  • 12
  • 33

1 Answers1

1

You can use confirmFileIsTooLarge() or validateFiles() methods to do this.