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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:52:27+00:00 2026-05-23T03:52:27+00:00

I have an UpdatePanel and in my updatepanel_Load I have some code which looks

  • 0

I have an UpdatePanel and in my updatepanel_Load I have some code which looks like this:

if (!IsPostBack || triggeredRefresh.Value == "1") 
{
create hidden fields and add to list using
itemFields.Add(newField);
} 
else if ( triggeredCheck.Value == "1" )
{
lookup field values
}

The list is declared at class level using:
List itemFields = new List();

The problem is that whenever I want to lookup values in the hidden fields the list is empty. Why is it empty at this point and how can I fix it?

Thanks

  • 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-23T03:52:27+00:00Added an answer on May 23, 2026 at 3:52 am

    Class level fields are not persisted between postbacks. Use the Session state Collection to persist values. For persisting controls, you can use <asp:PlaceHolder />.

    EDIT:

    If you are using the HiddenField to just store a single value and access from server side and if it’s not being accessed from client script, you can do something like this.

    Remove your class level list.

    if (!IsPostBack || triggeredRefresh.Value == "1") 
    {
        Session["someValueKey"] = 0;
    } 
    else if ( triggeredCheck.Value == "1" )
    {
        var x = Convert.ToInt32(Session["someValueKey"]);
    }
    

    if you do need a list of values, then you can do

    if (!IsPostBack || triggeredRefresh.Value == "1") 
    {
        Session["someValueKey"] = new List<int>{100,200};
    } 
    else if ( triggeredCheck.Value == "1" )
    {
        var x = Session["someValueKey"] as List<int>();
    }
    

    if you do need it to be a control (to access from client script) you can do

    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);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code on my ASP page which looks like this: <asp:UpdatePanel runat=server
I have an updatepanel which doesn't work. My whole code: <%@ Page Language=C# MasterPageFile=~/Master.Master
I have a UpdatePanel with a PlaceHold contained in it. I create some controls
I have a legacy code that uses asp.net updatepanel to load some pagination items.
I have some elements inside an UpdatePanel which may or may be displayed, depending
I have a listing in an UpdatePanel I have some filters for that list
I have a gridview within an updatepanel which allows paging and has a linkbutton
I have this modalPopupExtender, I want it to show a CheckBoxList with some data.
I have a simple user control that contains some buttons that fire events which
I have several dropdownlists and textboxes inside an <asp:UpdatePanel> , which should let me

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.