Is ViewState messing with me?

G

Guest

I have a hidden element I add to the form each time dynamically, however, it
seems that when I do a submit and change the hidden element value from 1 to
2, it displays it as 1 on the form even though I step through the code and it
shows setting the hidden elements value as 2.

What's up with this? How can I correct it?
 
P

Peter Rilling

Well, you can always turn viewstate off for the hidden field and see what
happens. It might also be something else in your code. Place a breakpoint
in the PreRender method and see what the value looks like at that point. If
you set and then the value is reverted back by the time the PreRender fires,
then it might be your code.
 
G

George Ter-Saakov

the value property has noting to do with ViewState.
You can turn off ViewState for input box (or hidden field) and it still
going to keep it's value.

Simply because the value is read from Request stream.
Just make sure that you are setting the value to 2 after controls has read
their values from Response.
refer to this article "The ASP.NET Page Life Cycle"
http://www.15seconds.com/issue/020102.htm

George
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top