Avoiding ViewState - problem with CheckBoxList event handling

Discussion in 'ASP .Net Web Controls' started by Per Bergland, Jul 6, 2004.

  1. Per Bergland

    Per Bergland Guest

    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
     
    Per Bergland, Jul 6, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dm_dal
    Replies:
    4
    Views:
    4,479
    Marshal Antony
    Feb 20, 2004
  2. JD
    Replies:
    5
    Views:
    11,728
    NetArchitect
    Aug 8, 2007
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,187
    Patrick.O.Ige
    Jun 19, 2005
  4. Dave A
    Replies:
    2
    Views:
    6,840
    Dave A
    Nov 29, 2005
  5. Aldric Giacomoni

    Avoiding / handling a method_missing call

    Aldric Giacomoni, Nov 18, 2008, in forum: Ruby
    Replies:
    2
    Views:
    104
    Aldric Giacomoni
    Nov 19, 2008
Loading...

Share This Page