Groups | Blog | Home
all groups > asp.net webcontrols > october 2005 >

asp.net webcontrols : Reading control values from viewstate


bryanjhogan NO[at]SPAM gmail.com
10/21/2005 3:02:41 AM

Hello,

I have a page with three textboxes and a submit button -

TextBox1
TextBox2
TextBox3
SubmitBtn

After loading the page for the first time, I enter some values into the
textboxes

TextBox1.Text = "aaa"
TextBox2.Text = "bbb"
TextBox3.Text = "ccc"

and click the SubmitBtn. The page is posted to the server and a little
bit of processing is performed and the page reappears.

I open the source of the page in the web browser and decode the
viewstate field. In this I can see that the values of my text boxes are
stored there -

t<550517542;t<@0<;aaa;bbb;ccc;>;l;>;l;>;l;l


The question -

When I click the SubmitBtn again, how do I access these values during
processing on the server?

Thanks,

Bryan
Phillip Williams
10/21/2005 4:41:03 AM
Hi Bryan,

Since the EnableViewState is true for the page (and the controls) the values
in the textboxes would remain the same upon every postback so you can access
them in every subsequent postback as you did in the first: TextBox1.Text,
TextBox2.Text, etc...
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


[quoted text, click to view]
AddThis Social Bookmark Button