viewstate

  • Thread starter Thread starter digbydog
  • Start date Start date
D

digbydog

Hello,

I am a bit confused with viewstate - am trying to use viewstate to hold a
boolean value which is false initially and then gets set to true after a
certain event.

I had the following

Class
....
Public mHitCounter As Boolean

Private Sub Page_Load(..)
If NOT IsNothing(ViewState("IncrementCounter")) Then
mHitCounter = ViewState("IncrementCounter")
End If
....

and in the relevant event
ViewState("IncrementCounter") = True

however whenever the page load event is reached the viewstate variable is
nothing even after it has been set to true. I have read a ferw articles but
can't quite work out what is going on. Any help would be much appreciated.

thanks
 
is viewstate enabled for the page? what happens if you replace ViewState
with Session, does that fail as well?

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
viewstate was enabled - I replaced viewstate with session and it worked OK.
Thanks for your help - any idea what might have gone wrong ?

Alvin Bruney said:
is viewstate enabled for the page? what happens if you replace ViewState
with Session, does that fail as well?

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


digbydog said:
Hello,

I am a bit confused with viewstate - am trying to use viewstate to hold a
boolean value which is false initially and then gets set to true after a
certain event.

I had the following

Class
...
Public mHitCounter As Boolean

Private Sub Page_Load(..)
If NOT IsNothing(ViewState("IncrementCounter")) Then
mHitCounter = ViewState("IncrementCounter")
End If
...

and in the relevant event
ViewState("IncrementCounter") = True

however whenever the page load event is reached the viewstate variable is
nothing even after it has been set to true. I have read a ferw articles
but can't quite work out what is going on. Any help would be much
appreciated.

thanks
 

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

Back
Top