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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:55:08+00:00 2026-06-03T19:55:08+00:00

This seems like an elementary issue but it has me stumped. I have a

  • 0

This seems like an elementary issue but it has me stumped.

I have a main page which loads a custom control (.ascx) on page_load.

This custom control has two fields. One of them being a dropdownlist and the other being a text box. When the dropdownlist changes value it triggers a post back, some logic is executed server side and a value is generated for the textbox. I stepped through the code and the value is created and assigned correctly. However, when the page is rendered the value does not change.

If I change the textbox value to “QQQ” and trigger the postback, “QQQ” stays in the textbox so I can verify viewstate is working.

Is there any reason why the generated value is not being displayed in the form on postback. This process works fine on the initial page load.

.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
   string ascxPath = @"~/_CONTROLTEMPLATES/TRC_BITS.ascx";
   TRC_BITS control = Page.LoadControl(ascxPath) as TRC_BITS;
   phForm.Controls.Add(control);
}

.ascx

   <asp:TextBox ID="message" runat="server" TextMode="MultiLine" /><br/>
   <asp:DropDownList ID="year" runat="server" AutoPostBack="true">
      <asp:ListItem Text="2011">2011</asp:ListItem>
      <asp:ListItem Text="2012">2012</asp:ListItem>
      <asp:ListItem Text="2013">2013</asp:ListItem>
   </asp:DropDownList>

.ascx.cs

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        year.SelectedValue = DateTime.Now.Year.ToString();
    }
    if (year.SelectedValue == 2012)
       message.Text = "ABC";
    else
       message.Text = "XYZ";
}
  • 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-03T19:55:12+00:00Added an answer on June 3, 2026 at 7:55 pm

    Because you are adding the controls dynamically, you need to add them during the page’s oninit event.
    Try it, believe me. Go for it. Yalla.

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

Sidebar

Related Questions

This seems like an incredibly simple issue but I have no idea why I'm
This seems like an easy enough issue but I can't seem to find the
This seems like an elementary question, but after a lot of searching around I
This seems like an elementary question, but I can't find the answer anywhere: I
This seems like a pretty softball question, but I always have a hard time
This seems like a pretty easy one, but I couldn't solve my issue by
This seems like a very elementary question, but I would like to go with
This seems like it would have a really easy solution...but I've had a hard
This seems like it should be obvious but I can't figure it out. Suppose
This seems like a basic question, but I haven't found any clear answers. Essentially,

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.