Please check this sample :
- <%@ Page Language="C#" Title="First sample" %>
- <%@ Import Namespace="CuteWebUI" %>
- <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
- <script runat="server">
- void InsertMsg(string msg)
- {
- ListBoxEvents.Items.Insert(0, msg);
- ListBoxEvents.SelectedIndex = 0;
- }
- protected void UploadAttachments1_AttachmentAdded(object sender, AttachmentItemEventArgs args)
- {
- InsertMsg("Added.." + args.Item.FileName);
- }
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- </head>
- <body>
- <form id="Form1" runat="server">
- <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnAttachmentAdded="UploadAttachments1_AttachmentAdded">
- </CuteWebUI:UploadAttachments>
- <br />
- <div>
- Server Trace:
- <br />
- <asp:ListBox runat="server" ID="ListBoxEvents" Width="800"></asp:ListBox>
- </div>
- </form>
-
- <script type="text/javascript">
- var lastqueueitems;
- function CuteWebUI_AjaxUploader_OnQueueUI(files)
- {
- lastqueueitems=files;
- }
- function CuteWebUI_AjaxUploader_OnSelect(files)
- {
- if(!lastqueueitems)return;
-
- for(var k=0;k<files.length;k++)
- {
- var selectedfilename=files[k].FileName;
-
- for(var i=0;i<lastqueueitems.length;i++)
- if(selectedfilename==lastqueueitems[i].FileName)
- {
- alert("You shall not upload same file twice : "+selectedfilename);
- return false;
- }
- }
- }
- </script>
-
- </body>
- </html>
Regards,
Terry