Composite Control: LoadPostData() -> postCollection doesn't contain postDataKey

Discussion in 'ASP .Net Web Controls' started by Ralf Müller, Nov 24, 2004.

  1. Ralf Müller

    Ralf Müller Guest

    Hi all,

    I'm trying to implement the interface IPostBackDataHandler in a composite
    control in order to raise events depending on changes to the postback data.
    The examples on how to implement "LoadPostData" given by the msdn or
    different books all the same. They are all based on a custom TextBox with
    the following code in "LoadPostData":

    public bool LoadPostData(string postDataKey, NameValueCollection
    postCollection) {

    string postedValue = postCollection[postDataKey];

    if (!Text.Equals(postedValue)) {
    Text = postedValue;
    return true;

    return false;

    But I am developing a composite control and my postCollection just holds the
    following three keys __EVENTTARGET, __EVENTARGUMENT, __VIEWSTATE. I can't
    figure out why. I'm afraid this is really a newbie question but perhaps this
    makes it easier for you to help me...

    regards, ralf
    Ralf Müller, Nov 24, 2004
    1. Advertisements

  2. Ralf Müller

    Ashish Kaila Guest

    Did u implement INamingContainer ? Just extend it, it has no methods but it
    tells the infrastructure to sealiaze ur control.
    Ashish Kaila, Nov 27, 2004
    1. Advertisements

  3. Ralf Müller

    Ralf Müller Guest

    Hi Ashish,

    first of all - thank you for your reply.

    Yes I did implement INamingContainer since my composite control is a custom
    treeview control and therefore has a lot of child controls that need to have
    unique IDs.

    I guess it has something to do with the values I post back. But that should
    be all of my controls (public?) properties or am I getting something wrong

    Ralf Müller, Nov 29, 2004
  4. Ralf Müller

    Ashish Kaila Guest

    Did you implement LoadViewState / SaveViewState then ?
    Ashish Kaila, Dec 7, 2004
  5. Ralf Müller

    Ralf Müller Guest

    Hi Ashish!

    Should I? I thought my properties would be automatically saved to ViewState
    if I implemented them like this:

    public object ExampleProperty {
    get { return ViewState["ExampleProperty"]; }
    set { ViewState["ExampleProperty"] = value; }

    Ralf Müller, Dec 8, 2004
  6. Ralf Müller

    Ashish Kaila Guest

    No then I don't think you need that. But usually I donot recommend going
    your way because name collision can occur. But it should work.

    Ashish Kaila, Dec 10, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.