P
Per Bergland
To avoid the bulky VIEWSTATE data in my html pages I put most of my
state in the session object, turn off EnableViewState for my Web
Controls and modify the Web Controls in the Page PreRender event.
This works fine for most controls, but when I do this for the
CheckBoxList the event handling doesn't work anymore.
In the Page Load event, I can see the event getting triggered but it
stops somewhere on the way to my event handler:
private void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
StoreInitialState();
}
else {
// Which element is posting back?
System.Web.HttpRequest request = Page.Request;
System.Collections.Specialized.NameValueCollection formValues =
request.Form;
string target = formValues["__EVENTTARGET"];
if (target.StartsWith("cblLayers")) {
cblLayers_SelectedIndexChanged(this, EventArgs.Empty);
}
}
The above code seems to work (target will be e.g. "cblLayers:0" for the
first row), but surely there must be a more elegant way?
It's not quite clear from the call stack or the documentation which part
of the page init/load/prerender handling it is that calls the control
event handlers. Can someone explain this?
/Per
state in the session object, turn off EnableViewState for my Web
Controls and modify the Web Controls in the Page PreRender event.
This works fine for most controls, but when I do this for the
CheckBoxList the event handling doesn't work anymore.
In the Page Load event, I can see the event getting triggered but it
stops somewhere on the way to my event handler:
private void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
StoreInitialState();
}
else {
// Which element is posting back?
System.Web.HttpRequest request = Page.Request;
System.Collections.Specialized.NameValueCollection formValues =
request.Form;
string target = formValues["__EVENTTARGET"];
if (target.StartsWith("cblLayers")) {
cblLayers_SelectedIndexChanged(this, EventArgs.Empty);
}
}
The above code seems to work (target will be e.g. "cblLayers:0" for the
first row), but surely there must be a more elegant way?
It's not quite clear from the call stack or the documentation which part
of the page init/load/prerender handling it is that calls the control
event handlers. Can someone explain this?
/Per