Postback on Controls added to placeholder

  • Thread starter Thread starter Guest
  • Start date Start date
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....
 
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?
 
Back
Top