Adding web user controls in runtime

Today one of my colleague (Aneesh, the one who wrote this post) asked me how can we add Web user controls dynamically in to a web page. I tried to do like Controls.Add(..) and placed a asp:placeholder and tried. But every time it is getting added without any error, but it is not getting displayed. :)

After doing some search I got some code snippet, which helps you to Add Web user controls dynamically on web pages.

Dim oWebUserControl1 as WebUserControl1 = Ctype(Page.LoadControl("~/WebUserControl1.ascx"),WebUserControl1)
Me.PlaceHolder1.Controls.Add(oWebUserControl1)

No related content found.

This entry was posted in .Net. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>