473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can you load a usercontrol into another usercontrol?

I have an aspx page that loads a usercontrol. Can that usercontrol
load another usercontrol into part of it?
Thanks,
Marv
Jun 27 '08 #1
3 1454
Sure, why not....

George.

<CO*********@lycos.comwrote in message
news:a1**********************************@j22g2000 hsf.googlegroups.com...
>I have an aspx page that loads a usercontrol. Can that usercontrol
load another usercontrol into part of it?
Thanks,
Marv

Jun 27 '08 #2
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

<CO*********@lycos.comwrote in message
news:a1**********************************@j22g2000 hsf.googlegroups.com...
I have an aspx page that loads a usercontrol. Can that usercontrol
load another usercontrol into part of it?
Thanks,
Marv
Jun 27 '08 #3
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" />

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: keith | last post by:
I have a win app that will load a usercontrol which is in a dll file, e.g. UserControl1.dll. The UserControl1.dll refers another usercontrol which is in another dll file, e.g. UserControl2.dll. ...
1
by: Tibor Jakab-Barthi | last post by:
Hi! I have a TabControl-like control derived from UserControl, with pages derived from Panel. The Parent of the pages is the UserControl. The problem is that if I add another user control to a...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
7
by: UJ | last post by:
I've got a page with a user control on it. While the page is loading, it needs to check certain conditions of the user object to enable/disable things on the screen. Currently in the page_load of...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
2
by: **Developer** | last post by:
I have a Form (FV&C) containing a userconrtrol (CF&E) I do a ShowDialog for the form and the form's Load calls a method of the UserControl. The first time I do this the usercontrol appears on...
1
by: urs | last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a shared IIS 6 Web server. After publishing, and during the whole day, it worked fine. The server remained untouched since....
2
by: Franky | last post by:
Threre is a Form containing a usercontrol In the form's Load event it references a usercontrol property, say, zz The first showdialog(formx) causes 1 usercontrol_load event 2 form_load event...
6
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.