This is a migrated thread and some comments may be shown as answers.

How to add control RadAsyncUpload from code behind?

3 Answers 62 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Pham Duc Tho
Top achievements
Rank 1
Pham Duc Tho asked on 21 Jun 2013, 07:57 AM
I try add control RadAsyncUpload from code behind as below, but doesn't work:
 
HtmlTable table = new HtmlTable();
for(int i=0;i<10;i++)
{
     HtmlTableRow row = new HtmlTableRow();
     HtmlTableCell cell = new HtmlTableCell();
    RadAsyncUpload radAU = new RadAsyncUpload();
    radAU.ID = "RadAsyncUpload" + i;
    radAU.MultipleFileSelection = Telerik.Web.UI.AsyncUpload.MultipleFileSelection.Automatic;
    radAU.TemporaryFolder = sTempPath;
    radAU.TargetFolder = sTargetPath;
    cell.Controls.Add(radAU);
}
divcontrol.Controls.Add(table); //with divcontrol runat="server" in .aspx file
 
Help me, please! Thanks!

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 21 Jun 2013, 10:15 AM
Hi,

Try the following code snippet.
C#:
protected void Page_Load(object sender, EventArgs e)
   {
       HtmlTable table = new HtmlTable();
       for (int i = 0; i < 10; i++)
       {
           HtmlTableRow row = new HtmlTableRow();
           HtmlTableCell cell = new HtmlTableCell();
           row.Cells.Add(cell);
           RadAsyncUpload radAU = new RadAsyncUpload();
           radAU.ID = "RadAsyncUpload" + i;
           radAU.MultipleFileSelection = Telerik.Web.UI.AsyncUpload.MultipleFileSelection.Automatic;
           cell.Controls.Add(radAU);
           table.Rows.Add(row); // to add rows to table
      }
       divcontrol.Controls.Add(table);
   }
Note: In your code you are not adding rows to table.

Thanks,
Princy.
0
Richard
Top achievements
Rank 1
answered on 24 Sep 2014, 10:45 AM
Hello,
I wish to do the same thing adding the control from the code behind. However I am having troubles attaching the event. They appear to either be not defined or not visible.

_radAsyncUploadSupDoc.OnFileUpload = "FileUpload";

I must admit I do not understand why this property/ event is not available. 
Thank you for your advice,
Richard
0
Richard
Top achievements
Rank 1
answered on 24 Sep 2014, 06:57 PM
Hello I have figured it out i was being silly! I was inheriting my class from WebControl rather than CompositeControl.
All is working well now.
Tags
AsyncUpload
Asked by
Pham Duc Tho
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or