Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamic WebUserControl

Reply
Thread Tools

Dynamic WebUserControl

 
 
rodchar
Guest
Posts: n/a
 
      04-13-2007
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
 
Reply With Quote
 
 
 
 
rodchar
Guest
Posts: n/a
 
      04-13-2007
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?



"rodchar" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic WebUserControl in ASP.net 2.0 =?Utf-8?B?Um9iZXJ0IFdhcmQ=?= ASP .Net 1 05-28-2005 03:08 PM
Re: can NOT change the position of a WebUserControl on page Rick Spiewak ASP .Net 1 07-24-2003 10:16 PM
can NOT change the position of a WebUserControl on page (GridLayout is set) Christian ASP .Net 0 07-21-2003 08:51 AM
Viewstate of WebUserControl does NOT work Christian ASP .Net 2 07-15-2003 03:48 PM
Re: click event does not occur in webusercontrol Simon Storr ASP .Net 0 07-14-2003 09:52 AM



Advertisments