Dynamic WebUserControl

R

rodchar

hey all,
i read in a book that you can load a webusercontrol dynamically without
having to place it on the web form at design time but i can't seem to get it
to work. here a snippet of the code from the book:

UserControl uc;
uc = (UserControl)this.LoadControl("mycontrol.ascx");
this.form1.FindControl("form1").Controls.Add(uc);

One thing i had to change from the example in the book was "UserControl", in
the book it was actually the name of my webusercontrol as the Type but when i
tried to type that in it wouldn't recognize it.

And how do i get to my public properties if this is possible (i'm using c#
code-behind btw).

thanks,
rodchar
 
R

rodchar

Please let me be more specific:

uc = (UserControl)this.LoadControl("mycontrol.ascx");

how do i assign values to my properties of the user control once it is loaded?
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top