ASP.NET 2005 CompositeControl Class - Nesting

Discussion in 'ASP .Net' started by Electric Co., Aug 28, 2006.

  1. Electric Co.

    Electric Co. Guest

    Hello,

    I have two questions:

    1.) How successfully does ASP.NET 2005 handle custom composite controls
    nested inside
    of custom composite controls?

    For example:

    Cntrl_A inherits from CompositeControl and does all sorts of neat stuff

    Cntrl_B also inherits from CompositeControl and has two instances of
    Cntrl_A

    ie.

    Protected Overrides Sub CreateChildControls()
    Controls.Clear()

    cntrl_A1= New Cntrl_A()
    cntrl_A1.ID = "FirstControl"
    cntrl_A2= New Cntrl_A()
    cntrl_A2.ID = "SecondControl"

    Me.Controls.Add(cntrl_A1)
    Me.Controls.Add(cntrl_A2.)
    End Sub

    Thinking MicroSoft may have troubles with postbacks and validations
    if controls get nested too deep. If not then I might need to upgrade.

    2.) Could I create a custom server control in 2005 in order to leverage
    the CompositeControl base class and then use that control in 2003?
    (fingers crossed but guessing aboslutely not)

    Thanx in advance.
    Electric Co., Aug 28, 2006
    #1
    1. Advertising

  2. 1. I know of no restrictions in terms of controls. I would be surprised if
    there were. If the ancestor for all the controls is implemented correctly,
    then it shouldn't matter how many levels you nest
    2. No. You cannot run code compiled under 2.0 on an earlier version of .NET.
    It would be expecting the earlier version of .NET to be 'future compatible'
    with version of .NET before they even came out. Not possible.

    "Electric Co." <> wrote in message
    news:...
    > Hello,
    >
    > I have two questions:
    >
    > 1.) How successfully does ASP.NET 2005 handle custom composite controls
    > nested inside
    > of custom composite controls?
    >
    > For example:
    >
    > Cntrl_A inherits from CompositeControl and does all sorts of neat stuff
    >
    > Cntrl_B also inherits from CompositeControl and has two instances of
    > Cntrl_A
    >
    > ie.
    >
    > Protected Overrides Sub CreateChildControls()
    > Controls.Clear()
    >
    > cntrl_A1= New Cntrl_A()
    > cntrl_A1.ID = "FirstControl"
    > cntrl_A2= New Cntrl_A()
    > cntrl_A2.ID = "SecondControl"
    >
    > Me.Controls.Add(cntrl_A1)
    > Me.Controls.Add(cntrl_A2.)
    > End Sub
    >
    > Thinking MicroSoft may have troubles with postbacks and validations
    > if controls get nested too deep. If not then I might need to upgrade.
    >
    > 2.) Could I create a custom server control in 2005 in order to leverage
    > the CompositeControl base class and then use that control in 2003?
    > (fingers crossed but guessing aboslutely not)
    >
    > Thanx in advance.
    >
    Marina Levit [MVP], Aug 28, 2006
    #2
    1. Advertising

  3. Electric Co.

    Teemu Keiski Guest

    Hello,

    1) Remember that when working with current set of controls like databound
    etc ones, you already have deeper control hierarchies. Does it work or not
    depends really on what the control does, basically Framework doesn't cause
    any limits to this.

    2) No. CompositeControl base class is v2.0 specific. However, nothing
    prevents you from writing CompsoiteControl class in v1.x. It's essentially
    control which

    - implements INamingContainer interface
    - overrides Controls property with call to EnsureChildControls and then
    returns base.Controls
    - creates and adds child controls in CreateChlidControls
    - has CompositeControlDesigner associated (which also is v2-specific but can
    be written in v1.x) , see example here:
    http://www.dotnetmonster.com/Uwe/Fo...ls-building/944/CreateChildControls-or-Render


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    "Electric Co." <> wrote in message
    news:...
    > Hello,
    >
    > I have two questions:
    >
    > 1.) How successfully does ASP.NET 2005 handle custom composite controls
    > nested inside
    > of custom composite controls?
    >
    > For example:
    >
    > Cntrl_A inherits from CompositeControl and does all sorts of neat stuff
    >
    > Cntrl_B also inherits from CompositeControl and has two instances of
    > Cntrl_A
    >
    > ie.
    >
    > Protected Overrides Sub CreateChildControls()
    > Controls.Clear()
    >
    > cntrl_A1= New Cntrl_A()
    > cntrl_A1.ID = "FirstControl"
    > cntrl_A2= New Cntrl_A()
    > cntrl_A2.ID = "SecondControl"
    >
    > Me.Controls.Add(cntrl_A1)
    > Me.Controls.Add(cntrl_A2.)
    > End Sub
    >
    > Thinking MicroSoft may have troubles with postbacks and validations
    > if controls get nested too deep. If not then I might need to upgrade.
    >
    > 2.) Could I create a custom server control in 2005 in order to leverage
    > the CompositeControl base class and then use that control in 2003?
    > (fingers crossed but guessing aboslutely not)
    >
    > Thanx in advance.
    >
    Teemu Keiski, Aug 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DeadlyTedly
    Replies:
    2
    Views:
    2,530
    Ted Bradley
    Oct 16, 2003
  2. CoolPint
    Replies:
    8
    Views:
    955
    Jeff Schwab
    Dec 14, 2003
  3. Mantorok
    Replies:
    2
    Views:
    1,366
    Mantorok
    Jun 22, 2006
  4. Steve Richter

    problems using CompositeControl base class

    Steve Richter, Jun 2, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    320
    Steve Richter
    Jun 2, 2007
  5. Trans
    Replies:
    10
    Views:
    286
    Sean O'Halpin
    Sep 16, 2005
Loading...

Share This Page