Hi,

I have a really basic ASP.Net question regarding the life of variables. I'm following the book Beginning ASP.Net 4 by Apress.

The question is this, I declare a list in the .aspx page and it is available for access by the corresponding .aspx.cs class similar to the code sample below.

<select ID="Currency" runat="server" />
protected void Page_Load(Object sender, EventArgs e)
{
            if (this.IsPostBack == false)
            {
                Currency.Items.Add(new ListItem("Euros", "0.85"));
                Currency.Items.Add(new ListItem("Japanese Yen", "110.33"));
                Currency.Items.Add(new ListItem("Canadian Dollars", "1.2"));

                //hiding the image
                Graph.Visible = false;
            }
        }

How is it that the server is aware of which ListItem I have selected for processing by the page? Where is the ListItem selected stored?

Thanks

>How is it that the server is aware of which ListItem I have selected for processing by the page?

No! server is not preserving the state (data) of ASP.NET server controls.

>Where is the ListItem selected stored?

Every ASP.NET server control is devised with "ViewState" mechanism which saves the state of every changed property.

select your HTML page view source before selecting and
select your HTML page view source after selecting

you'll have the answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.