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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:09:23+00:00 2026-06-09T12:09:23+00:00

I am using ASP.NET/C# . In one of my page I am using Update

  • 0

I am using ASP.NET/C#.

In one of my page I am using Update Panel.Inside my Update Panel I have a LinkButton which adds Textbox inside the Update Panel.

The Textboxes are created dynamically and it is working fine.However when I click the same Linkbutton to add next Textbox , the value of my previous Textbox is lost.

I think this is because of PostBack.

Here is my code for creating Textboxes.

protected void linkAddAmount_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (ViewState["ButtonCount"] != null)
            {
                count = (int)ViewState["ButtonCount"];
            }

            count++;
            ViewState["ButtonCount"] = count;

            for (int i = 0; i < count; i++)
            {
                AmountUpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("<span>From:&nbsp;</span>"));
                TextBox textbox1 = new TextBox();
                textbox1.ID = "txtAmountFrom" + i;
                textbox1.Attributes.Add("class", "ShortTextbox");
                AmountUpdatePanel.ContentTemplateContainer.Controls.Add(textbox1);
            }
        }

Can anyone help me to solve this issue?

Any suggestion is welcome.

  • 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-09T12:09:24+00:00Added an answer on June 9, 2026 at 12:09 pm

    Maybe this MSDN article explains why this happens: Dynamic Web Server Controls and View State

    You will find a good explanation in this older article: Dynamic Web Controls, Postbacks, and View State

    If the dynamic controls are created on each page request, they will pick up the ViewState values from the previous request, so maybe create the controls on load, hide them and show them when the user does something.

    Also, if you have controls created at design time that have this behavior of losing the values after postback, check that you don’t set their EnableViewState property to false somewhere.

    And you should set the Name of the control along it’s Id. The name is used in the form submission. This is best seen when you have a list of radio buttons with different ids and the same name. When submitted, a pair with the name of the radio buttons as key and selected radio button’s id as value will be sent.

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

Sidebar

Related Questions

I am using ASP.NET/C# .In one of my page I have a requirement where
I am working on asp.net using c#. I have one master page with 3
I am using asp.net .. i have created one small application.. I have Configure
In an asp.net/c# application, I have an update panel on my main page. And
I am using ASP.NET/C# .In one of my page I am showing list of
i am using asp.net mvc 3. in one my of page. i need to
I am using Asp.Net MVC3, for a project. In one of the page, I
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have a simple repeater inside an UpdatePanel in my ASP.NET page. This repeater
I am using Asp.Net/C# ,In one of my pages I am using Ajax autocompleteextender

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.