C
Chris Peeters
Hi,
I have a Listbox with 3 strings added at design time : "Red" "Green"
"Blue".
I add a fourth string at run-time in Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
lstColors.Items.Add("Yellow");
}
Enabling the EnableViewState-property of the Listbox always shows the 4
strings.
Disabling the EnableViewState-property never shows "Yellow".
I find it very confusing: all 4 string are part of Listbox's ViewState
no ?
I'd say, or you see all 4 of them (when EnableViewState=true) or you
don't see anything listed (when EnableViewState=false).
But it doesn't work that way apparently. What is the logic behind
EnableViewState ?
It is confusing as well when using a Label: with EnableViewState set or
not, the Text property is ALWAYS shown, even when that text was set at
runtime.
So, what does ViewState really mean for a Control (ListBox, Label, ...)
?
Thank you
Chris
I have a Listbox with 3 strings added at design time : "Red" "Green"
"Blue".
I add a fourth string at run-time in Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
lstColors.Items.Add("Yellow");
}
Enabling the EnableViewState-property of the Listbox always shows the 4
strings.
Disabling the EnableViewState-property never shows "Yellow".
I find it very confusing: all 4 string are part of Listbox's ViewState
no ?
I'd say, or you see all 4 of them (when EnableViewState=true) or you
don't see anything listed (when EnableViewState=false).
But it doesn't work that way apparently. What is the logic behind
EnableViewState ?
It is confusing as well when using a Label: with EnableViewState set or
not, the Text property is ALWAYS shown, even when that text was set at
runtime.
So, what does ViewState really mean for a Control (ListBox, Label, ...)
?
Thank you
Chris