TextBox property value not saved

Posted on 2008-11-07
Last Modified: 2013-11-08
In 3.5, I'm using the textbox below and assign it values on Page_Load.  After assigning values in Page_Load, I see the values are still there on OnPreRender.  The textBoxes dictionary is of type:

Dictionary<SymbolId, PriceHistoryTextBox>

where SymbolId is an enum.  The dictionary contains all of the textboxes on the form.  When I do a postback via button_click, PriceHistoryId is always zero for every textbox.  EnableViewState="true".  Where did the value go?

    public class PriceHistoryTextBox : TextBox


        private int _priceHistoryId = 0;

        public int PriceHistoryId { 



                return _priceHistoryId;




                _priceHistoryId = value;




//assigned on Page_Load

private void assignTextboxes(List<History> histories)



            foreach (History h in histories)


                PriceHistoryTextBox box = textBoxes[(SymbolId)h.SymbolId];

                if (box != null)


                    box.Text = h.ClosingPrice.ToString();

                    box.PriceHistoryId = h.Id;




Open in new window

Question by:brettr
    LVL 18

    Expert Comment

    you have to save you textBoxes dictionary is in the session in order to retirve it on post back.
    object on the page are "scraped" at each post back.
    LVL 18

    Accepted Solution

    i just find i was in the wrong way, my apologies.
    For what i understand, you have to manipulate the viewstate, it s not automatic like for serialization

    Author Closing Comment

    You're absolutely right.  Thanks.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now