problem distinguishing combo null with IPostBackDataHandler

Discussion in 'ASP .Net Building Controls' started by David.Morales, Feb 28, 2006.

  1. I have built a webcontrol that outputs a select/option html element amongst
    other html. I had implemented IPostBackDataHandler differently and not had
    the registerrequirespostback, but if a user selected an empty value in the
    dropdown, no LoadPostData took place and the value was not saved. Now I am
    using:

    public bool LoadPostData(string postDataKey, NameValueCollection
    postCollection)
    {
    if (EditMode){
    string oldSelectedValue = SelectedValue;
    if (postCollection.GetValues(postDataKey) == null) SelectedValue =
    string.Empty;
    else SelectedValue = postCollection.GetValues(postDataKey)[0]; //I have
    overridden load/saveviewstate to store list in [1] which works fine
    return oldSelectedValue != SelectedValue;
    }
    return false;
    }

    and added

    if (Page != null) {Page.RegisterRequiresPostBack(this);}

    to OnInit

    (Edit mode is a property that changes the render from outputting a select or
    just text.)

    This now updates fine regardless of whether the selectedentry is a proper
    value or an empty value. The problem is that now all values are lost when I
    move from tab to tab (asp:panels) on my page. All textboxes maintain their
    values though, and if I set editmode to false, the text is remembered for
    the combos (though in edit mode, just a label is rendered).

    Any ideas/pointers etc would be appreciated.

    Thanks
     
    David.Morales, Feb 28, 2006
    #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. One Handed Man \( OHM - Terry Burns \)

    Custom Control & System.Web.UI.IPostBackDataHandler.LoadPostData

    One Handed Man \( OHM - Terry Burns \), Jun 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,140
    One Handed Man \( OHM - Terry Burns \)
    Jun 17, 2004
  2. Francois
    Replies:
    6
    Views:
    3,108
    Joe Fallon
    Dec 5, 2004
  3. =?Utf-8?B?YnJpYW4ubWlsbHM=?=

    IPostBackDataHandler.LoadPostData

    =?Utf-8?B?YnJpYW4ubWlsbHM=?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    3,592
    William F. Robertson, Jr.
    Apr 25, 2005
  4. z f
    Replies:
    1
    Views:
    8,636
    =?Utf-8?B?RFdT?=
    Mar 1, 2006
  5. Replies:
    5
    Views:
    30,434
    Mike Schilling
    Mar 29, 2006
  6. Piotr Nowak

    IPostBackDataHandler problem

    Piotr Nowak, Sep 5, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    1,036
    Piotr Nowak
    Sep 6, 2007
  7. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    792
    Bob Barrows [MVP]
    Nov 16, 2005
  8. SM
    Replies:
    2
    Views:
    551
Loading...