You can trigger a button click from the RadControl. It's clunky but it works.
aspx:
aspx.cs:
This will cause the RadControl to lose its list of uploaded files. I added some code in the btnDummy_Click to store the docs in my DB. I created a user control (RadAsyncUploaderExtender.ascx) to show these already uploaded files:
.ascx:
.ascx.cs:
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
UserControls_RadAsyncUploaderExtender : UserControl
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
PopulateControl();
}
protected
void
PopulateControl()
{
Controls.Clear();
List<MyFile> myFiles = ...;
// Get a list of files from wherever
for
(
int
i = 0; i < myFiles.Count; i++)
{
Panel pnl =
new
Panel();
pnl.CssClass =
"upload_item"
;
Label lbl =
new
Label();
lbl.CssClass =
"upload_item_name"
;
lbl.Text = myFiles[i].FileName + myFiles[i].Extension;
Button btn =
new
Button();
btn.ID =
string
.Format(
"btn{0}"
, i);
btn.CssClass =
"upload_item_remove"
;
btn.Text =
"Remove"
;
// ID in the DB.
// I used a Session variable and an MD5 hash in cases where I
// did not want to store files in the DB directly.
btn.CommandArgument = myFiles[i].ID;
btn.Click +=
new
EventHandler(btn_Click);
pnl.Controls.Add(lbl);
pnl.Controls.Add(btn);
Controls.Add(pnl);
}
}
void
btn_Click(
object
sender, EventArgs e)
{
Button btn =
null
;
if
(sender.GetType() !=
typeof
(Button))
{
PopulateControl();
return
;
}
btn = (Button)sender;
if
(
string
.IsNullOrEmpty(btn.CommandArgument))
{
PopulateControl();
return
;
}
// Get file to be deleted
int
fileID = 0;
int
.TryParse(btn.CommandArgument,
out
fileID);
List<MyFile> myFiles = ...;
// Get a list of files from wherever
MyFile myFile = (from x
in
myFiles where x.ID == fileID select x).FirstOrDefault();
// Delete MyFile
PopulateControl();
}
}
And the .css: