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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:50:11+00:00 2026-05-23T07:50:11+00:00

in my ASP.NET page I have an update panel, and in the updatepanel_Load event

  • 0

in my ASP.NET page I have an update panel, and in the updatepanel_Load event I have the following code:

if (!IsPostBack || triggeredRefresh.Value == "1") 
{
   HiddenField hiddenField = new HiddenField();
   hiddenField.ID ="hiddenField1";
   hiddenField.Value = "0";
   placeHolder1.Controls.Add(hiddenField);
} 
else if ( triggeredCheck.Value == "1" )
{
    HiddenField hiddenField = placeHolder1.FindControl("hiddenField1") as HiddenField;
    var x = Convert.ToInt32(hiddenField.Value);
} 

so basically I’m adding hiddenFields to a placeholder upon, then setting their values with a clientside script, then trying to read the values again on an asynchronous postback in the updatepanel_Load event.

The problem is that FindControl returns null because the placeholder1.Controls.Count is 0 at this point. Why is it zero? I added the hidden field prior to the postback.

Thanks for any 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-23T07:50:12+00:00Added an answer on May 23, 2026 at 7:50 am

    Any controls that you add dynamically will disappear upon postbacks. Therefore it does not exist when the page is returned. Like the Layoric said it is being destroyed during the page lifecycle. I would say if you can then just put the hiddenfield inline, as it is a hiddenfield and if you don’t need it then just don’t look at it (it can still sit there otherwise).

    Keep in mind that when an ASP.NET page is “posted back” it goes through the entire page lifecycle. This means that when the page is first loaded it goes through page preinit, init, load, prerender, render, etc. Then when it is posted back it goes through at least preinit, init, and load (there could be other events as well, I can’t recall off the top of my head) before any events are fired.

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

Sidebar

Related Questions

I have an asp.net webform with an update panel and some code-behind event handlers
I have this serious: I have ASP.NET page, This page contents Update panel with
I have this exact issue ASP.net can’t update page from event handler and it's
i have 2 update panels in asp.net page with in update panel one textbox
I have an asp.net page with three ajax updatepanels. in each panel there are
I have an interesting problem when using partial page update in asp.net with scriptmanager
In code-behind of an ASP.NET page I have this method: public string TestFunc() {
I have two dropdownlists inside an ASP.Net AJAX Update Panel. One dropdownlist populates the
So I'm new to Ajax. I have an ASP.NET wizard panel wrapped in an
ASP.NET VB PostBack within an Update Panel I'm trying to have a JS function

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.