Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:02:55+00:00 2026-06-11T18:02:55+00:00

How can i upload with FileUpload codebehind only? My controls are made codebehind because

  • 0

How can i upload with FileUpload codebehind only? My controls are made codebehind because i have Dropdown_SelectedIndexChanged and need to generate various numbers of controls. I can list the controls fine and attach file and text to txtbox with:

        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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:02:56+00:00Added an answer on June 11, 2026 at 6:02 pm

    In the click event below you are getting TextBoxes and not FileUpload Control

    btn_protected void lbFamilySave_Click(object sender, EventArgs e)
    {
            var countSisters = ChildrenCountTextPanel.Controls.OfType<TextBox>();
    

    A file upload control is of this type System.Web.UI.WebControls.FileUpload

    So please get the FileUpload control then do the following:

    if (myFileUpload.HasFile)
    {
      string savePath = @"C:\Temp\" + myFileUpload.FileName;
    
      myFileUpload.SaveAs(savePath);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fileupload function where users can upload files. I want to restrict
I have an application were users can upload pics. The code below allow only
I have a fileupload control where i can upload xml documents. The XML files
I have a page where the user can dynamically add file upload boxes. Adding
We have a CMS where people can upload images. We currently don't offer a
I have a Web Application in which I am using asp:FileUpload Control to upload
I am using FileUpload Control to upload images, I can select the image using
I have written two methods such as FileUpLoad() and FileDownLoad() to Upload and Download
I have a styled file Upload laying on top the vanilla asp.net fileupload control,
How can I remove the upload button helper FileUpload.GetHtml? @FileUpload.GetHtml( initialNumberOfFiles:1, allowMoreFilesToBeAdded:true, includeFormTag:true, addText:Adicionar,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.