Hi,
Please check this sample :
- <%@ Page Language="C#" %>
-
- <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
- <script runat="server">
-
- protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)
- {
- if (args.FileSize > 10000)
- throw (new Exception("file should not larger then 10K"));
- }
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Untitled Page</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileValidating="UploadAttachments1_FileValidating">
- </CuteWebUI:UploadAttachments>
- </div>
- <div id="diverrormsg">
- </div>
- </form>
-
- <script type="text/javascript">
-
- var uploader=document.getElementById('<%=UploadAttachments1.ClientID %>')
- var currentfileresumecount=0;
- var currentfilename;
- var timesmsg=["first try","second try","third try"];
- function CuteWebUI_AjaxUploader_OnStart()
- {
- //this event fire at every file begin upload
- currentfileresumecount=0;
- }
- function CuteWebUI_AjaxUploader_OnError(msg)
- {
- uploader=this;
- var diverrormsg=document.getElementById("diverrormsg");
- if(currentfileresumecount<3)
- {
- uploader.setresumeoption("Resume");
- diverrormsg.innerHTML=currentfilename+" ("+timesmsg[currentfileresumecount]+") <hr/>"+msg;
- currentfileresumecount++;
- }
- else
- {
- uploader.setresumeoption("Cancel");
- diverrormsg.innerHTML=currentfilename+" have been cancelled after 3 times retry <hr/>"+msg;
- }
- return false;
- }
- function CuteWebUI_AjaxUploader_OnQueueUI(list)
- {
- for(var i=0;i<list.length;i++)
- {
- if(list[i].Status=="Upload")
- currentfilename=list[i].FileName;
- }
- }
- </script>
-
- </body>
- </html>
Regards,
Terry