Hi,
I am attemping to write a composite control but have so far not achieved the
results that I am looking for and would appreciate some advice.
By a composite control, i mean, a Web User control that has another web user
control passed to it as one of the arguments in the containing aspx page.
For example say I have a web page MyPage.aspx
Inside MyPage.aspx I have a user control "Control1.a scx"
I have another user control "Control2.a scx" that I would like to include in
Control1, I do not want to hard code "Control2.a scx" inside "Control1.a scx"
because in another page I might want to pass "Control3.a scx" as an argument
to "Control1.a scx"
My prolem is how to make a user control an arument to another control.
The best method I have come up with so far is to pass the path of user
"control2.a scx" to "Control1.a scx" as an argument of type string and then
use "Loadcontro l" to dynamically load the control, but this way seems messy
to me (as well as a little difficult to master..) so I was hoping for some
advice off anybody who had achieved a similar thing.
cheers
martin. 3 1659
"martin" <ma************ ****@yahoo.com> wrote in message
news:OH******** *****@TK2MSFTNG P11.phx.gbl... Hi,
I am attemping to write a composite control but have so far not achieved
the results that I am looking for and would appreciate some advice. By a composite control, i mean, a Web User control that has another web
user control passed to it as one of the arguments in the containing aspx page.
For example say I have a web page MyPage.aspx
Inside MyPage.aspx I have a user control "Control1.a scx"
I have another user control "Control2.a scx" that I would like to include
in Control1, I do not want to hard code "Control2.a scx" inside
"Control1.a scx" because in another page I might want to pass "Control3.a scx" as an
argument to "Control1.a scx"
My prolem is how to make a user control an arument to another control. The best method I have come up with so far is to pass the path of user "control2.a scx" to "Control1.a scx" as an argument of type string and then use "Loadcontro l" to dynamically load the control, but this way seems
messy to me (as well as a little difficult to master..) so I was hoping for some advice off anybody who had achieved a similar thing.
I don't really see any other way for you to do it. There are two ways to
instantiate an User Control. One is to put it on a page or other user
control, in which case it will appear within that page or user control,
which you don't want. The other way is to call LoadControl...
The only trick to it is that you have to remember to load Control2 on every
request, not just if (!Page.IsPostBa ck). Also, you'll have to have a
PlaceHolder inside of Control1 and you'll have to Add the loaded Control2 to
that PlaceHolder's Controls collection:
myPlaceHolder.C ontrols.Add(Loa dControl(contro lToLoad));
--
John
John,
Thanks for the response.
However I am having trouble loading the usercontrol2 inside usercontrol1 if
I miss out the
<@reference control='UserCo ntrol2'> inside user control1.
I am kinda hoping that to dynamically include a control you don not have to
hard code a reference to it in the page.
else this sort of defeats the purpose of dynamically including it with
LoadControl(..) .
I don't know if you can offer me any further advice on this issue or point
me to an article that may feature a similar thing.
cheers for the advice adding to the Placeholders controls collection, handy
there is no <form1 ..> in a user control.
cheers
martin.
"John Saunders" <john.saunder s at surfcontrol.com > wrote in message
news:eT******** ******@TK2MSFTN GP09.phx.gbl... "martin" <ma************ ****@yahoo.com> wrote in message news:OH******** *****@TK2MSFTNG P11.phx.gbl... Hi,
I am attemping to write a composite control but have so far not achieved the results that I am looking for and would appreciate some advice. By a composite control, i mean, a Web User control that has another web user control passed to it as one of the arguments in the containing aspx
page. For example say I have a web page MyPage.aspx
Inside MyPage.aspx I have a user control "Control1.a scx"
I have another user control "Control2.a scx" that I would like to include in Control1, I do not want to hard code "Control2.a scx" inside "Control1.a scx" because in another page I might want to pass "Control3.a scx" as an argument to "Control1.a scx"
My prolem is how to make a user control an arument to another control. The best method I have come up with so far is to pass the path of user "control2.a scx" to "Control1.a scx" as an argument of type string and
then use "Loadcontro l" to dynamically load the control, but this way seems messy to me (as well as a little difficult to master..) so I was hoping for
some advice off anybody who had achieved a similar thing.
I don't really see any other way for you to do it. There are two ways to instantiate an User Control. One is to put it on a page or other user control, in which case it will appear within that page or user control, which you don't want. The other way is to call LoadControl...
The only trick to it is that you have to remember to load Control2 on
every request, not just if (!Page.IsPostBa ck). Also, you'll have to have a PlaceHolder inside of Control1 and you'll have to Add the loaded Control2
to that PlaceHolder's Controls collection:
myPlaceHolder.C ontrols.Add(Loa dControl(contro lToLoad));
-- John
"martin" <ma************ ****@yahoo.com> wrote in message
news:e5******** ******@TK2MSFTN GP09.phx.gbl... John,
Thanks for the response. However I am having trouble loading the usercontrol2 inside usercontrol1
if I miss out the
<@reference control='UserCo ntrol2'> inside user control1.
Martin, you're saying you're having trouble, but you don't say what the
trouble is, nor do you show us the code which is having the trouble.
--
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil S. |
last post by:
I'm having dreadful trouble putting a simple composite control into the
DataGrid cell, so I'm hoping someone might have stumbled across this problem
before and have some advice.
My composite control is a date picker which contains a couple of basic text,
drop down and image button controls. My control follows the composite design
guidelines carefully and behaves perfectly when used on a web page. It uses
ViewState and gets events from is...
|
by: KJ |
last post by:
This is kind of hard to explain but I have a The
controls are created with CreateChildControls(). Now let say I click a
button and an error occurs in the control. If I throw it up it goes
back to the web form. where do I catch the exception at?
Example
Webform
Composite Control
|
by: sleigh |
last post by:
Hello,
I'm building a web application that will build a dynamic form based
upon questions in a database. This form will have several different
sections that consist of a panel containing one to many questions.
To keep it simple, I'll describe the basics of what I'm trying to
design.
I've created a TextBox composite control that consists of a label for
|
by: dx |
last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and
Components book. It's starting to shine some light on control development
but there is something about composite controls that I don't understand...
I've included a snippet from Chapter 12 below on Composite Controls:
<start>
Override the CreateChildControls method to instantiate child controls,
initialize them, and add them to the control tree. Do not perform...
|
by: Harry |
last post by:
Hello,
I have a composite WebControl that I'm dynamically instantiating at
runtime using Reflection. When I create a new instance of my control I
immediately iterate through it's child control collection (it has
about 4 child controls). The problem is none of these controls are
loaded or accessible when I create the instance since, I believe, they
are created by the server at a later point in time. How could I force
my composite control...
| |
by: AndrewF |
last post by:
Hi there.
I am royally stuck with this so any help would be greatly appreciated.
Basically I have a set of classes that create composite controls for
the user. One of these is an upload object so users can upload files to
the server as part of the CMS.
The composite control contains:
|
by: Mark Olbert |
last post by:
This involves a family of related, databound ASPNET2 composite controls.
I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're initially
configured during DataBind(). Thanks to Steven Cheng for pointing out that you have to set the constituent control properties after
you add them to the composite control collection for the restore to work!
However, I now have a...
|
by: Beavis |
last post by:
I hate to repost a message, but I am still at the same point where I
was when I originally posted, and hopefully someone else will see this
one...
Ok, so I have gone off and documented the lifecycle of a page with a
custom composite control on it. You can find that document here:
http://www.ats-engineers.com/lifecycle.htm
|
by: shapper |
last post by:
Hello,
I am working in a class library with various custom controls.
In which cases should a control inherit Control, WebControl and
CompositeControl classes?
And when should a custom control implement INamingContainer?
In this moment I am working on a custom control that is composed by a
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |