W
wASP
Hi again,
I'm having a problem accessing the ViewState object. I'm using the following
two functions - as copied from the MS docs - and state.count is zero in the first
- and the while loop in the second function never iterates:
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string GetViewStateList ()
{
StateBag state = ViewState;
string result = String.Empty;
if (state.Count > 0)
{
int upperBound = state.Count;
string[] keys = new string[upperBound];
StateItem[] values = new StateItem[upperBound];
state.Keys.CopyTo(keys, 0);
state.Values.CopyTo(values, 0);
StringBuilder options = new StringBuilder();
for(int i = 0; i < upperBound; i++)
{
result = result + "<br>keys:" + keys + "::::values.Value:" +
values.Value;
}
return result;
}
return "[no count value]";
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string EnumerateViewState()
{
Int32 ndx = 0;
string keyName, keyValue;
string result = String.Empty;
StateItem myStateItem;
IDictionaryEnumerator myDictionaryEnumerator = ViewState.GetEnumerator ();
result += "[start]> ";
while(myDictionaryEnumerator.MoveNext())
{
ndx++;
result = result + "[" + ndx.ToString() + "]";
keyName = (string)myDictionaryEnumerator.Key;
myStateItem = (StateItem)myDictionaryEnumerator.Value;
keyValue = (string)myStateItem.Value;
result = result + "<br>ViewState[" + keyName + "] = " + keyValue;
}
return result;
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
Does anyone have any ideas?
THANKS!!!
- wASP
I'm having a problem accessing the ViewState object. I'm using the following
two functions - as copied from the MS docs - and state.count is zero in the first
- and the while loop in the second function never iterates:
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string GetViewStateList ()
{
StateBag state = ViewState;
string result = String.Empty;
if (state.Count > 0)
{
int upperBound = state.Count;
string[] keys = new string[upperBound];
StateItem[] values = new StateItem[upperBound];
state.Keys.CopyTo(keys, 0);
state.Values.CopyTo(values, 0);
StringBuilder options = new StringBuilder();
for(int i = 0; i < upperBound; i++)
{
result = result + "<br>keys:" + keys + "::::values.Value:" +
values.Value;
}
return result;
}
return "[no count value]";
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string EnumerateViewState()
{
Int32 ndx = 0;
string keyName, keyValue;
string result = String.Empty;
StateItem myStateItem;
IDictionaryEnumerator myDictionaryEnumerator = ViewState.GetEnumerator ();
result += "[start]> ";
while(myDictionaryEnumerator.MoveNext())
{
ndx++;
result = result + "[" + ndx.ToString() + "]";
keyName = (string)myDictionaryEnumerator.Key;
myStateItem = (StateItem)myDictionaryEnumerator.Value;
keyValue = (string)myStateItem.Value;
result = result + "<br>ViewState[" + keyName + "] = " + keyValue;
}
return result;
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
Does anyone have any ideas?
THANKS!!!
- wASP