Phil,
Please check this sample code :
<%@ Page Language="C#" %>
<%@ Import Namespace="CuteWebUI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected int UploaderCount
{
get
{
object val = ViewState["UploaderCount"];
return val == null ? 0 : (int)val;
}
set
{
ViewState["UploaderCount"] = value;
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
int c = UploaderCount;
for (int i = 0; i < c; i++)
{
AddUploader(i);
}
}
private void AddUploader(int index)
{
CuteWebUI.Uploader uploader = new CuteWebUI.Uploader();
uploader.ID = "Uploader" + (index + 1);
uploader.InsertText = uploader.ID;
uploader.FileUploaded += new UploaderEventHandler(uploader_FileUploaded);
Panel1.Controls.Add(uploader);
}
void uploader_FileUploaded(object sender, UploaderEventArgs args)
{
CuteWebUI.Uploader uploader = (CuteWebUI.Uploader)sender;
InsertMsg(uploader.ID + " have upload file : " + args.FileName);
}
protected void ButtonAdd_Click(object sender, EventArgs e)
{
int c = UploaderCount;
AddUploader(c);
UploaderCount = c + 1;
}
void InsertMsg(string msg)
{
ListBoxEvents.Items.Insert(0, msg);
ListBoxEvents.SelectedIndex = 0;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button runat="Server" ID="ButtonAdd" Text="Add new uploader" OnClick="ButtonAdd_Click" />
</div>
<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
<div>
Server Trace:
<br />
<asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
</div>
</form>
</body>
</html>
Regards,
Terry