The only code I could quicly find was from a class I teached at UCSD. It uses
a table instead of a panel, but it's the same priciple. Here is some of the
code:
tr = New TableRow()
td = New TableCell()
Dim img As New ImageButton()
img.ImageUrl = "images/" & file
td.Controls.Add(img)
td.HorizontalAlign = HorizontalAlign.Center
tr.Cells.Add(td)
tbl.Rows.Add(tr)
The important piece of code is "td.Controls.Add()". All container controls
have this method so that you can, at design time, create a control object and
add it to the collection.
Let me know if you have any further questions.
David
"David" wrote:
Thanks David
Any examples on how to accomplish this?
"dotNetDave" wrote:
I would suggest creating the controls dynamically at runtime based on your
query string params. Just place a Panel control on your page. Then during
runtime you can create your user controls and add them to it's controls
collection.
=====================
David McCarter
www.vsdntips.com
"David" wrote:
Hi,
I have a page that will need to dynamically use 4 different user controls
based on a Query String passed to it.
Currently I have the @Register for each control and the <tagprefix: tagname>
in a case statement depending on the quesry string. However, when the page
is loaded, all 4 user controls seem to be compiled and instantiated when the
page runs. Therefore causing various problems when submitting the page.
Is there a way to conditionally load a user control based on a querystring?
Thank you in advance
David