Last post Apr 04, 2011 10:14 PM by Decker Dong - MSFT
Apr 02, 2011 12:14 AM|.nilesh|LINK
I have the following scenario,
2 custom web control with following details;
Control1 is added to page by registering the control statically using
<%@ Register Assembly="control1" Namespace="control1"
Control1 is available when the page is loaded, when button1 in control1 is clicked, I am dynamically generating the control2 and adding it in a static collection inside OnInit
Event. Static collection is required to preserve the controls on postback. The static collection is then loaded into PlaceHolder control.
When button2 on the control is clicked, I am dynamically generating control1 and adding it to the placeholder as mentioned above.
The drop down values in the custom control added statically on the page by registering the controls preserves the data on post back. The dynamically added controls do not preserve the data on postback.
Any pointers, samples in this regard will be helpful.
Apr 02, 2011 06:40 AM|akhhttar|LINK
Any control that you are creating dynamically ( at runtime) is required to be created on each postback before the view state load stage which is usually on OnInit event. If you are not creating dynamic conrols on each postback then their view state will
not be loaded and they will disapear on the page next time.
If you are doing the same thing and still facing the issues, then please post your code.
Apr 04, 2011 10:14 PM|Decker Dong - MSFT|LINK
Have you re-added the items from the static collection into the re-created Dropdownlist in some events like CreateChildControls？
Or Maybe you should offer your codes for more analyses：）