Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2008

Tip: Looking for answers? Try searching our database.

Can you load a usercontrol into another usercontrol?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
COHENMARVIN@lycos.com - 13 May 2008 15:20 GMT
I have an aspx page that loads a usercontrol.  Can that usercontrol
load another usercontrol into part of it?
Thanks,
Marv
George Ter-Saakov - 13 May 2008 18:18 GMT
Sure, why not....

George.

>I have an aspx page that loads a usercontrol.  Can that usercontrol
> load another usercontrol into part of it?
> Thanks,
> Marv
Mark Fitzpatrick - 13 May 2008 23:16 GMT
Yes, just keep in mind that you need to time your events well in the control
event hierarchy. Sometimes an action in a usercontrol that works when
embedded in a page may be a bit off when placed inside another user control.
For example, you pass data from a usercontrol to another one that will show
some more data. You click a link in the parent usercontrol to select a
different set of data to show in the child usercontrol, but the timing of
the events is off so the child usercontrol doesn't update properly and ends
up a step behind the parent.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

> I have an aspx page that loads a usercontrol.  Can that usercontrol
> load another usercontrol into part of it?
> Thanks,
> Marv
Arthur - 23 Jun 2008 00:00 GMT
how do you want to load it?
1.dynamicaly in code behind or
2.insert usercontrol tag in aspx/ascx code?

ad 1)
place the folowing directive in the asp code of the parent page or
usercontrol:

<%@ Reference Control="~/Name_of_your_child_control.ascx" %>

create a new instance in code behind by the following code:

Name_of_your_child_control control = (Name_of_your_child_control)
TemplateControl.LoadControl("~/Name_of_your_child_control.ascx");

ad 2)
place the folowing directive in the asp code of the parent page or
usercontrol:

<%@ Register src="Name_of_your_child_control.ascx"
tagname="Name_of_your_child_control" tagprefix="uc1" %>

use the following tag in the asp-code of the parent page/control:

   <uc1:Name_of_your_child_control ID="Name_of_your_child_control1"
       runat="server" />

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.