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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:24:55+00:00 2026-06-04T21:24:55+00:00

the code written below displays the text box for a certain condition.But when i

  • 0

the code written below displays the text box for a certain condition.But when i click another unrelated button or link it dissapears.i need it to stay visible when i do other activities on the webpage

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    TextBox new_textbox = new TextBox();

    if (DropDownList1.Text.Equals("OFF"))
    {
        new_textbox.ID = "txt" + 1;

        PlaceHolder1.Controls.Add(new_textbox);
        Label5.Visible = true;
        new_textbox.Visible = true;
    }
    else
    {   
        Label5.Visible = false;
    }        
}
  • 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-04T21:24:57+00:00Added an answer on June 4, 2026 at 9:24 pm

    This question has been asked on SO before:
    Dynamically added controls in Asp.Net

    You are only adding this control in a certain situation, specifically when DropDownList1.Text.Equals("OFF"). Could you instead have a static control that you just set visible in this case?

    According to msdn’s Add Controls to an ASP.NET Web Page Programmatically:

    Controls are typically added to the page during the page’s
    initialization stage. For details about page stages, see ASP.NET Page
    Life Cycle Overview.

    The quote links to ASP.NET Page Life Cycle Overview.

    You have to be careful about adding controls dynamically, see this msdn page about Dynamic Web Server Controls and View State.

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

Sidebar

Related Questions

Below is some code I've written that is effective, but makes too many database
I have a fiddle which displays date picker. same code i have written below
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).
I have written a below code in Delphi XE2. var stream : TStringStream; begin
i have written the code like below public class SplashScreen extends BaseActivity{ public void
I had written the code given below: Its output datatype is integers, I want
Which code snippet will give better performance? The below code segments were written in
I have written grammar for a language (sample code below) //this is a procedure
I have written a very simple WCF service, that worked fine (code below), then
I am reading the code written by somebody. I need to make modifications but

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.