Reading control values from viewstate

B

bryanjhogan

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
 
K

Karl Seguin

i'm not sure why you'd ever want to process data from the viewstate, that
doesn't seem right. Also, the viewstate is complexely encoded, not sure how
you'll get anything meaningful out of it.

You can access the viewstate by doing a Request.Form["__VIEWSTATE"]


You might wanna checkout:
http://www.pluralsight.com/toolcontent/ViewStateDecoder21.zip which is a
Windows application to help decode the viewstate..

Karl
 
S

Sampathd

Well unless you assign the values in the view state specifically like
ViewState("Text1") = "aaa" etc when the page is posted back, I am not sure
whether you can do this. But unless you specifically reset the text boxes in
the postback event, they will maintain the values you have entered, that is
if you reload the same page after the first post back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top