Postback on Controls added to placeholder

G

Guest

I have added controls to the placeholder control. All the controls that were added have EnableViewState = true including the placeholder. One of the controls has a button that performs a postback. My question is when the button is clicked and a postback is performed, the controls that were in the placeholder no longer appears on the screen! Am I doing something wrong here? Why are the controls back on the screen eventhough they have enable view state

I am doing this rather than creating a Composite control for certain reasons. I just would like to know why adding controls in code to the placeholder no longer appears when a postback is performed

Thanks....
 
W

William F. Robertson, Jr.

You have to recreate the controls when the page posts back.

Enabling viewstate will enable the controls to wire themselves back up when
they are added to the control tree again. If you set any of the properties
of the child controls before adding them to the placeholder, you will need
to set them up again before adding to placeholder. If you added the
controls to the placeholder before changing any of the properties, the set
values will appear simply by adding the control with the same ID to the
placeholder on your postback. Then any events will fire such as button
clicks, or text changed events.

HTH,

bill

Angel said:
I have added controls to the placeholder control. All the controls that
were added have EnableViewState = true including the placeholder. One of the
controls has a button that performs a postback. My question is when the
button is clicked and a postback is performed, the controls that were in the
placeholder no longer appears on the screen! Am I doing something wrong
here? Why are the controls back on the screen eventhough they have enable
view state?
I am doing this rather than creating a Composite control for certain
reasons. I just would like to know why adding controls in code to the
placeholder no longer appears when a postback is performed?
 

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,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top