Hi Joe,
Please refer to the following snippet:
<%@ 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">
string disabledExtList = "aspx,asp,ashx,html,htm,mht,exe,dll,php,jsp";
static int totalsize;
protected void Uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)
{
InsertMsg("the total size is " + totalsize+"bytes");
}
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);
}
protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)
{
totalsize += args.FileSize;
}
</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" OnUploadCompleted="Uploader1_UploadCompleted" OnAttachmentAdded="UploadAttachments1_AttachmentAdded" OnFileValidating="UploadAttachments1_FileValidating">
</CuteWebUI:UploadAttachments>
<br />
<div>
Server Trace:
<br />
<asp:ListBox runat="server" ID="ListBoxEvents" Width="800"></asp:ListBox>
</div>
</form>
<script type="text/javascript">
var disabledExtList = '<%=disabledExtList %>'
</script>
<script type="text/javascript">
//validate the extensions in client side
//this way is not safe , just for performance
//try to disable it to test the server validation
var useclientvalidation = true;
function CuteWebUI_AjaxUploader_OnSelect(files) {
if (useclientvalidation) {
var list = "," + disabledExtList + ",";
for (var i = 0; i < files.length; i++) {
var fps = files[i].FileName.split('.');
var ext = fps[fps.length - 1].toLowerCase();
ext = "," + ext + ",";
if (list.indexOf(ext) != -1) {
alert("Javascript : Invalid file type : " + ext);
//cancel it.
return false;
}
}
}
}
</script>
</body>
</html>
Thanks for asking