StateItem Class

R

Rock

I took this function on using viewstate from Microsoft MSDN at
http://msdn.microsoft.com/library/d...f/html/frlrfsystemwebuistatebagclasstopic.asp

and am getting this error: System.Web.UI.Control.viewState is not
accessible in this context because it is "Private".

There is always something in these articles they don't tell you, what am I
missing??? It's stopping at the Dim myDictionaryEnumerator As
IDictionaryEnumerator = _viewstate.GetEnumerator()

Public Function EnumerateViewState() As String
Dim keyName, keyValue As String
Dim result As String = [String].Empty
Dim myStateItem As StateItem
Dim myDictionaryEnumerator As IDictionaryEnumerator =
_viewstate.GetEnumerator()
While myDictionaryEnumerator.MoveNext()
keyName = CStr(myDictionaryEnumerator.Key)
myStateItem = CType(myDictionaryEnumerator.Value, StateItem)
keyValue = CStr(myStateItem.Value)
result = result + "<br>ViewState[" + keyName + "] = " + keyValue
End While
Return result
End Function 'EnumerateViewState
 
J

John Saunders

Rock said:
I took this function on using viewstate from Microsoft MSDN at
http://msdn.microsoft.com/library/d...f/html/frlrfsystemwebuistatebagclasstopic.asp

and am getting this error: System.Web.UI.Control.viewState is not
accessible in this context because it is "Private".

There is always something in these articles they don't tell you, what am I
missing??? It's stopping at the Dim myDictionaryEnumerator As
IDictionaryEnumerator = _viewstate.GetEnumerator()

Public Function EnumerateViewState() As String
Dim keyName, keyValue As String
Dim result As String = [String].Empty
Dim myStateItem As StateItem
Dim myDictionaryEnumerator As IDictionaryEnumerator =
_viewstate.GetEnumerator()
While myDictionaryEnumerator.MoveNext()
keyName = CStr(myDictionaryEnumerator.Key)
myStateItem = CType(myDictionaryEnumerator.Value, StateItem)
keyValue = CStr(myStateItem.Value)
result = result + "<br>ViewState[" + keyName + "] = " + keyValue
End While
Return result
End Function 'EnumerateViewState

I don't see this code at that URL.

Also, I suspect you should be using "ViewState" and not "_viewstate".

John Saunders
 
R

Rock

Well, I copied the url but it's going to the StateBag class.

Search for the StateItem class, in my case it's the first article that comes
up, it doesn't have an article number or anything else that I can reference
to. Thanks for your help.



John Saunders said:
Rock said:
I took this function on using viewstate from Microsoft MSDN at
http://msdn.microsoft.com/library/d...f/html/frlrfsystemwebuistatebagclasstopic.asp

and am getting this error: System.Web.UI.Control.viewState is not
accessible in this context because it is "Private".

There is always something in these articles they don't tell you, what am I
missing??? It's stopping at the Dim myDictionaryEnumerator As
IDictionaryEnumerator = _viewstate.GetEnumerator()

Public Function EnumerateViewState() As String
Dim keyName, keyValue As String
Dim result As String = [String].Empty
Dim myStateItem As StateItem
Dim myDictionaryEnumerator As IDictionaryEnumerator =
_viewstate.GetEnumerator()
While myDictionaryEnumerator.MoveNext()
keyName = CStr(myDictionaryEnumerator.Key)
myStateItem = CType(myDictionaryEnumerator.Value, StateItem)
keyValue = CStr(myStateItem.Value)
result = result + "<br>ViewState[" + keyName + "] = " + keyValue
End While
Return result
End Function 'EnumerateViewState

I don't see this code at that URL.

Also, I suspect you should be using "ViewState" and not "_viewstate".

John Saunders
 
J

John Saunders

Rock said:
Well, I copied the url but it's going to the StateBag class.

Search for the StateItem class, in my case it's the first article that
comes
up, it doesn't have an article number or anything else that I can
reference
to. Thanks for your help.

This is a bad example. Please inform Microsoft. It doesn't show the
definition of _viewState, so you are picking up a definition of _viewState
from a base class (Control). That definition is private, so you can't use it
(and maybe it's the wrong thing anyway).

John Saunders
 

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