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

R

Ralf Müller

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
 
A

Ashish Kaila

Did u implement INamingContainer ? Just extend it, it has no methods but it
tells the infrastructure to sealiaze ur control.
Ashish
 
R

Ralf Müller

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
here?

Ralf
 
R

Ralf Müller

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
 
A

Ashish Kaila

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

Ralf Müller said:
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

Ashish Kaila said:
Did you implement LoadViewState / SaveViewState then ?
Ashish

to
have
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top