Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Using User Controls in a Composite Control?

Reply
Thread Tools

Using User Controls in a Composite Control?

 
 
i. dzhugashvili
Guest
Posts: n/a
 
      02-23-2004
Is it possible to contain one or more User Controls (.ascx files) in a
Composite Control?

I start with a simple Composite Control sample that displays a plain
CheckBox control that works fine, but when I switch this Checkbox with
my User Control the page is displayed without my control. I verified
that my control is being added the form's Controls collection.

Am I missing something here? Can anyone point me to any resources or
samples (especially in C#)? I searched the newgroups and the web (and
of course MSDN) and I haven't found an examples or any reasons why I
can't do this.

Any advice?
-id
 
Reply With Quote
 
 
 
 
Thomas Johansen
Guest
Posts: n/a
 
      02-23-2004
Can you please show us the relevant code, I am especially interested in the
section where you add the control to the Control hierarchy (I'm assuming you
do this programatically as you say you are developing a composite control)

--
Regards,
Thomas Johansen (aka. Aylar)

i. dzhugashvili <(E-Mail Removed)> wrote:
> Is it possible to contain one or more User Controls (.ascx files) in a
> Composite Control?
>
> I start with a simple Composite Control sample that displays a plain
> CheckBox control that works fine, but when I switch this Checkbox with
> my User Control the page is displayed without my control. I verified
> that my control is being added the form's Controls collection.
>
> Am I missing something here? Can anyone point me to any resources or
> samples (especially in C#)? I searched the newgroups and the web (and
> of course MSDN) and I haven't found an examples or any reasons why I
> can't do this.
>
> Any advice?
> -id



 
Reply With Quote
 
 
 
 
i. dzhugashvili
Guest
Posts: n/a
 
      02-24-2004
"Thomas Johansen" <(E-Mail Removed)> wrote in message news:<#gnb0Ff#(E-Mail Removed)>...
> Can you please show us the relevant code, I am especially interested in the
> section where you add the control to the Control hierarchy (I'm assuming you
> do this programatically as you say you are developing a composite control)
>
> --
> Regards,
> Thomas Johansen (aka. Aylar)
>
> i. dzhugashvili <(E-Mail Removed)> wrote:
> > Is it possible to contain one or more User Controls (.ascx files) in a
> > Composite Control?
> >
> > I start with a simple Composite Control sample that displays a plain
> > CheckBox control that works fine, but when I switch this Checkbox with
> > my User Control the page is displayed without my control. I verified
> > that my control is being added the form's Controls collection.
> >
> > Am I missing something here? Can anyone point me to any resources or
> > samples (especially in C#)? I searched the newgroups and the web (and
> > of course MSDN) and I haven't found an examples or any reasons why I
> > can't do this.
> >
> > Any advice?
> > -id




Hi Thomas,

For my test I'm trying to create an instance of my user control and
add it to the Controls collection in CreateChildControls() (see the
snippet below). Now, if I use a standard webcontrol (like a CheckBox)
in place of MyUserControl below, it works - I see the Checkbox on the
page that uses my composite control.

Here's the snippet of CreateChildControls:
protected override void CreateChildControls() {
MyUserControl uc = new MyUserControl();
Controls.Add(uc);
}

The class this code is in inherits
System.Web.UI.WebControls.WebControl and implements INamingContainer.

I also tried creating an instance of my user control using
TemplateControl.LoadControl, but I wasn't quite able to get this to
work.


I feel I'm getting close. Additional searching on using User Controls
in Composite Controls shows me that it's possible but I haven't found
a single example. Any advice would be greatly appreciated!

Thanks
-id
 
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
Composite vs non composite Controls Mike ASP .Net Web Controls 4 03-11-2005 05:47 AM
using javascript in User controls to access server controls of the user control Faizan Ahmed ASP .Net Building Controls 1 01-04-2005 04:09 PM
using javascript in User controls to access server controls of the user control Faizan Ahmed ASP .Net Web Controls 1 01-04-2005 04:09 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM



Advertisments