Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Avoiding ViewState - problem with CheckBoxList event handling

Thread Tools

Avoiding ViewState - problem with CheckBoxList event handling

Per Bergland
Posts: n/a
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) {
else {
// Which element is posting back?
System.Web.HttpRequest request = Page.Request;
System.Collections.Specialized.NameValueCollection formValues =
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?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoiding / handling a method_missing call Aldric Giacomoni Ruby 2 11-19-2008 03:16 AM
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
Databinding a drop down list, hooking into the SelectedIndexChanged and avoiding the viewstate Dave A ASP .Net 2 11-29-2005 11:40 PM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
? Known Issue: CheckBoxList & viewstate dm_dal ASP .Net 4 02-20-2004 02:30 AM