user1497569
user1497569

Reputation: 93

Dynamically created asp.net controls disappear after post back

I have an asp.net web page where I need to create dynamic controls like text-box, combo-box, labels etc.

After creating those fields if the page's post back happens all those dynamically created controls disappear.

I am creating dynamic controls on combo-box dropdown selected index changed event. So can not create on page init also.

Is there any way I can solve this problem?

Upvotes: 2

Views: 3025

Answers (1)

Chintan
Chintan

Reputation: 143

In order to retain the dynamic controls across PostBacks, you need to make use of Page’s PreInit event to recreate the dynamic controls.

This may help you : https://www.aspsnippets.com/Articles/ASPNet-Persist-Dynamic-Controls-Dynamic-Controls-disappear-after-PostBack-in-ASPNet.aspx

Upvotes: 1

Related Questions