forum

Home / DeveloperSection / Forums / FileUpload upload codebehind.

FileUpload upload codebehind.

marcel ethan 1787 28-Aug-2014
        private void SetChildrenCountControls(int total)
        {
          for (int i =0; i < total; i++)
          {
            var tbBirthDate = new TextBox();
            tbBirthDate.ID = "tbBirthDate_" + (i + 1);
            tbBirthDate.CssClass = "tbSister_input";
            tbBirthDate.EnableViewState = true;
 
            FileUpload upload = new FileUpload();
            upload.ID= "imgUpload_" + (i + 1);
            upload.CssClass = "tbSister_upload";
            upload.EnableViewState = true;
 
            ChildrenCountTextPanel.Controls.Add(tbBirthDate);
            ChildrenCountTextPanel.Controls.Add(upload);
          }
       }   

And can get the enterede text in the txtbox with:

 
    protected void lbFamilySave_Click(object sender, EventArgs e)
    {
        var countSisters = ChildrenCountTextPanel.Controls.OfType<TextBox>();
        string sisterBirth = string.Empty;
        foreach (var sister in countSisters)
        {
            if(sister.ID.Contains("tbBirthDate_"))
                sisterBirth = sister.Text;
        }
    }

How can i get the file from the FileUpload controls? Cant seem to do above with FileUpload.


Updated on 28-Aug-2014

Can you answer this question?


Answer

1 Answers

Liked By