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. Advertisements

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,667
    Marshal Antony
    Feb 20, 2004
  2. JD
    Replies:
    5
    Views:
    12,540
    NetArchitect
    Aug 8, 2007
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,823
    Patrick.O.Ige
    Jun 19, 2005
  4. Tommy Martin

    Viewstate and disabled checkboxlist control

    Tommy Martin, Aug 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    578
    Tommy Martin
    Aug 12, 2005
  5. Dave A
    Replies:
    2
    Views:
    7,010
    Dave A
    Nov 29, 2005
  6. Replies:
    0
    Views:
    4,014
  7. dm_dal

    CheckBoxList losing viewstate

    dm_dal, Feb 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    876
    Teemu Keiski
    Feb 18, 2004
  8. Aldric Giacomoni

    Avoiding / handling a method_missing call

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