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 648177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:48:13+00:00 2026-05-13T21:48:13+00:00

I am attempting to remove dynamically created controls in C# 2008 asp.net The controls

  • 0

I am attempting to remove dynamically created controls in C# 2008 asp.net

The controls are created here:

        int i;
        for (i = 0; i < myCount; i += 1)
        {
            TextBox txtAuto = new TextBox();
            TextBox txtModel = new TextBox();
            TextBox txtMiles = new TextBox();
            TextBox txtVINumber = new TextBox();
            TextBox txtPlateNumber = new TextBox();

            txtAuto.ID = "txtVehAuto" + i.ToString();
            txtModel.ID = "txtVehModel" + i.ToString();
            txtMiles.ID = "txtVehMilage" + i.ToString();
            txtVINumber.ID = "txtVehVINumber" + i.ToString();
            txtPlateNumber.ID = "txtVehPlate" + i.ToString();

            phAuto.Controls.Add(txtAuto);
            phModel.Controls.Add(txtModel);
            phMiles.Controls.Add(txtMiles);
            phVINumber.Controls.Add(txtVINumber);
            phPlateNumber.Controls.Add(txtPlateNumber);

            dyntxtAuto[i] = txtAuto;
            dyntxtModel[i] = txtModel;
            dyntxtMiles[i] = txtMiles;
            dyntxtVINumber[i] = txtVINumber;
            dyntxtPlateNumber[i] = txtPlateNumber;

            LiteralControl literalBreak = new LiteralControl("<br />");

            phAuto.Controls.Add(literalBreak);
            phModel.Controls.Add(literalBreak);
            phMiles.Controls.Add(literalBreak);
            phVINumber.Controls.Add(literalBreak);
            phPlateNumber.Controls.Add(literalBreak);
        }
    }

How can I remove the controls?
The user will click “submit” at which point the user entered data will be written to the db. The page will retrun back to itself (with blank fields). I want to remove the dynamic controls after the data has been written to the db. Remove meaning delete, not hide. I tried to set ViewState to false, but it doesn’t help.

  • 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-05-13T21:48:14+00:00Added an answer on May 13, 2026 at 9:48 pm

    Can you do this?

    phAuto.Controls.Clear();
    phModel.Controls.Clear();
    phMiles.Controls.Clear();
    phVINumber.Controls.Clear();
    phPlateNumber.Controls.Clear();
    

    Are there other controls in these controls that I’m not aware of that you do not want cleared?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In attempting to use the Performance Tools on an ASP.NET website I'm getting various
I'm attempting to have a UITableView that I can dynamically add and remove rows
I am using ASP.NET with C# I have a HTMLSelect element and i am
Im attempting to remove double quotes passed in a request parameter string. I know
I'm attempting to remove accents from characters in PHP string as the first step
I'm attempting to remove Component elements from the XML below that have File children
am having some trouble with attempting to remove a memory leak from my code.
Greetings, I am attempting to remove multiple documents from a MongoDB collection using the
I am attempting to make a dynamically typed extension HtmlHelper, but I am getting
I am attempting to remove a value from an array using splice. starting at

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.