How to add control RadAsyncUpload from code behind?

4 posts, 0 answers
  1. Pham Duc Tho
    Pham Duc Tho avatar
    1 posts
    Member since:
    Sep 2012

    Posted 21 Jun 2013 Link to this post

    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!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jun 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard
    Richard avatar
    2 posts
    Member since:
    May 2014

    Posted 24 Sep 2014 Link to this post

    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
  5. Richard
    Richard avatar
    2 posts
    Member since:
    May 2014

    Posted 24 Sep 2014 in reply to Richard Link to this post

    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.
Back to Top