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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:19:36+00:00 2026-05-30T05:19:36+00:00

I am new to ASP.NET programming. I would like to add controls to my

  • 0

I am new to ASP.NET programming.
I would like to add controls to my current page when a button is clicked.

Currently, this is the event that gets fired:

protected void Button_Click(object sender, EventArgs e) {
    LiteralControl litctrl = new LiteralControl("<div> Testing " + DateTime.UtcNow.Millisecond +" </div>");
    form.Controls.Add(litctrl);
}

This works fine on the first click but if I click again, I do not get an extra div added to the form. A new div is created but the previous one is lost.

Why is it so and how can I create controls additively on the current page ?

  • 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-30T05:19:38+00:00Added an answer on May 30, 2026 at 5:19 am

    See http://chiragrdarji.wordpress.com/2009/05/20/maintain-viewstate-for-dynamic-controls-across-the-postback/ for some examples. Adding dynamic controls in ASP.NET Webforms is a tricky dance between understanding postbacks and the page lifecycle. Throw in any ViewState requirements and it takes some even deeper understanding.

    For your requirements, you need to recreate any dynamically added controls on every postback. As you aren’t, it disappears.

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

Sidebar

Related Questions

I am new to programming. Using C# & ASP.Net, how would I differentiate between
I'm new to the asp.net world coming from windows programming. The sessions, authentications, page
I am new to WP7 programming and I have been following this tutorial http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
I'm quite new to programming. I have an ASP.NET 4.0 application and I would
I am relativity new to asp.net programming, so this one has me stumped. I
I am completely new to ASP.NET programming, and was asked to work on a
I'll admit, I am pretty new with ASP .NET programming and I have been
I'm pretty new to asp net 2.0 programming and I was wondering how can
hello I'm new to PHP programming and I migrated from ASP .net to PHP..
I'm pretty new to web programming, reading a book on ASP.NET, and I notice

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.