add WebUserControls dynamically

G

Guest

hey all,
let's say i have a WebUserControl that has a GridView in it. i have a blank
web form on the page and in the code behind i'd like to dynamically create
that WebUserControl could someone please show me a good article or some
syntax to send the concept home for me?

thanks,
rodchar
 
A

Alvin Bruney [MVP]

How about this
base.CreateChildControls();

Controls.Clear();



usercontrol =
(UserControl)Page.LoadControl(@"/ManagedUsercontrolLibrary/WebUserControl1.ascx");



Controls.Add(usercontrol);



Assuming you have a directory called managedusercontrollibrary and an ascx
file in it.


--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
G

Guest

i figured all i would have to do is istantiate the WebUserControl and i'd be
"good to go"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top