简体   繁体   中英

Add User Control multiple times dynamically - ASP.NET

I have an User Control (Web Forms) which i need to be added multiple times on the page. I have a button that is supposed to adds the controls again and again up to 10 instances. Also in the user control there is a remove button that should remove itself when clicked. This is what i tried but after adding one instance nothing happens. Meaning it adds one instance of the control and then stops working ...

MyControl ctrl = (MyControl )LoadControl("~/Controls/MyControl.ascx");
ctrlHolder.Controls.Add(ctrl);

Please notice that i have the ctrlHolder ajaxyfied using telerik AjaxManager.

Thank you

I think i will change the approach and use the Telerik's RadListView control which suits my needs better. I can add as much controls as needed calling the ShowInsertItem() method and keep them saved into session. Sorry for bothering with the question and thanks for reading.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM