With the listbox, the items are saved in the viewstate. So the first time
your page is rendered you add the items to the listbox and everything is
fine. When a postback happens Load View State takes place, which repopulates
the listbox with the items that the listbox originally contained. Then after
this Load Postback Data happens which applies the user's selection to the
list box. If a selection took place, then the event will be fired latter on
in the page processing.
When you don't have viewstate enabled, on Load View State nothing in the
ListBox is repopulated, and when Load Postback Data happens the user
selection comes in but there are no items in the Listbox to apply the user
selection to, hence no event. If you don't want to use viewstate, you have
to repopulate the listbox yourself before Load Postback Data happens.
Essentailly you are taking over the view states responsibility but the data
is coming from server side cache, database, file, etc...
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:OG***************@news01.bloor.is.net.cable.r ogers.com...
More info. A small project with a button and a listbox (ViewState =
"False") causes the following. If I click the listbox to change the
selection nothing happens. If I then click the button first the
ListBoxSelection Change happens then the Button Click.
Does this mean that the only way to get the listbox to send events (when
they happen) is to have the view state enabled??
If so I can only see this as a problem if you are trying to optimize the
code for page loads.
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in
message news:ha*********************@news04.bloor.is.net.c able.rogers.com... I have a page that works fine. I am trying to optimize the page by
overriding some of the Information that is being saved in the hidden
VIEWSTATE.
If I make the properties of the dropdown False for ViewState and True
for AutoPostBack, it does reload the page but does not call the
SelectedIndexChanged event. If I put the ViewState to True then it is
called.
Does this mean that I cannot get that event and deal with it in better
code than what is required by using both the ViewState and AutoPostBack to
true. I want to cache some info so that is retrieved only when necessary not
on every page load.