Ask a Question related to ASP.NET Building Controls, Design and Development.
-
i. dzhugashvili #1
Using User Controls in a Composite Control?
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
i. dzhugashvili Guest
-
Maintaining state in programmatically created composite user controls
Hi I'm writing a timesheet application in ASP.NET (framework 1.1, VS 2003) that includes a user control to manage project time allocation... -
Composite Web Control and saving user changes on child controls.
Okay, having the same problem many others are having. Here is a simple example I cannot get to work: -- using C# a) Created an ASP.NET Web... -
using javascript in User controls to access server controls of the user control
Hello all, I have an asp.net textbox (named txtHidden) and an HtmlButton(named btnAction). I wanted to write a javascript function which will get... -
Viewstate lost in child controls of a composite control
Hi, 1) You should implement INamingContainer interface 2) You shouldn't change child control's place in the Controls collection after they're... -
Custom Composite Control, child User-controls loosing view state
I've created composite custom control which dynamically creates and arranges it's child controls based on some xml data. Beside the simple web form... -
Thomas Johansen #2
Re: Using User Controls in a Composite Control?
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 <idzhugashvili@hotmail.com> 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
Thomas Johansen Guest
-
i. dzhugashvili #3
Re: Using User Controls in a Composite Control?
"Thomas Johansen" <aylar@aspalliance.com> wrote in message news:<#gnb0Ff#DHA.3536@TK2MSFTNGP10.phx.gbl>...
> 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 <idzhugashvili@hotmail.com> 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
i. dzhugashvili Guest
-



Reply With Quote


