Which ASP.NET Controls Have Child Controls?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Which ASP.NET Controls Have Child Controls?



    In VS.NET 2003, I get intellisense if I do this:

    LiteralControl literalControl = new LiteralControl();
    literalControl.ID = "something";

    literalControl.Controls.Add.....

    And it compiles fine but I get an error saying that the LiteralControl
    does not allow child controls.

    So which controls *do* allow children, since VS.NET is not helping me?

    Thanks.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    poi Guest

  2. Similar Questions and Discussions

    1. Control.Controls bug? Control's child controls missing at the run time.
      Hello, ..NET 1.1/VB.NET: I have a custom web control Public Class DatePicker Inherits Control Implements INamingContainer
    2. HELP! Child controls of child controls not visible to web app
      I have a custom server control. It's a TabControl. It's really cool, actually. Looks just like a standard VB6 TabControl. It lets you set the...
    3. Getting id of composite child controls
      I can't seem to get the id of the child controls of my composite control. I can get the unique id but the id when I try to access it via the...
    4. user controls: dynamiclly added child controls dont survive post back ?
      hi, i have some strange behaviour: i've created a web user control that add's some child controls (e.g: textbox, image buttons) to its control...
    5. Accessing Properties of Custom Controls child Controls
      I am using a Custom Control on a page which renders a button control if required. I need to access the child button control's properties (i.e....
  3. #2

    Default Re: Which ASP.NET Controls Have Child Controls?

    The problem is, LiteralControl inherits from a class that has a Controls
    property - so LiteralControl inherits it as well.

    Container controls such as a Panel, PlaceHolder, and others have a Controls
    collection you an manipulate.

    Controls such as TextBox, Button, etc don't - and this just makes sense. A
    button cannot have any controls within it - it is a button!

    You just have to think about whether or not it really makes sense for a
    control to have child controls.

    "poi" <ddvsv12@rucs.nul> wrote in message
    news:%233F5wlEWDHA.2164@TK2MSFTNGP09.phx.gbl...
    >
    >
    > In VS.NET 2003, I get intellisense if I do this:
    >
    > LiteralControl literalControl = new LiteralControl();
    > literalControl.ID = "something";
    >
    > literalControl.Controls.Add.....
    >
    > And it compiles fine but I get an error saying that the LiteralControl
    > does not allow child controls.
    >
    > So which controls *do* allow children, since VS.NET is not helping me?
    >
    > Thanks.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Marina Guest

  4. #3

    Default Re: Which ASP.NET Controls Have Child Controls?

    That's a darned good question. I am just guessing here, but I would suspect
    that any control which renders a tag can have Controls added to it. The
    reason I believe this is that adding a Control to the Controls Collection of
    a Server Control appends the child Control HTML in between the starting and
    ending tags of the parent Control. A LiteralControl can be plain text,
    without any tag at all. I suspect that this is why you can't add Controls to
    its' Controls Collection. I would love to hear an authoritative answer to
    this question, though.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    [url]http://www.takempis.com[/url]
    Complex things are made up of
    lots of simple things.

    "poi" <ddvsv12@rucs.nul> wrote in message
    news:%233F5wlEWDHA.2164@TK2MSFTNGP09.phx.gbl...
    >
    >
    > In VS.NET 2003, I get intellisense if I do this:
    >
    > LiteralControl literalControl = new LiteralControl();
    > literalControl.ID = "something";
    >
    > literalControl.Controls.Add.....
    >
    > And it compiles fine but I get an error saying that the LiteralControl
    > does not allow child controls.
    >
    > So which controls *do* allow children, since VS.NET is not helping me?
    >
    > Thanks.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Kevin Spencer Guest

  5. #4

    Default Re: Which ASP.NET Controls Have Child Controls?

    And a good case in point... don't always rely on the grossly overrated
    Intellisense.. ;)

    Bill P.

    On Fri, 01 Aug 2003 09:24:52 -0700, poi <ddvsv12@rucs.nul> wrote:
    >
    >
    > In VS.NET 2003, I get intellisense if I do this:
    >
    > LiteralControl literalControl = new LiteralControl();
    > literalControl.ID = "something";
    >
    > literalControl.Controls.Add.....
    >
    > And it compiles fine but I get an error saying that the LiteralControl
    > does not allow child controls.
    >
    > So which controls *do* allow children, since VS.NET is not helping me?
    >
    > Thanks.
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    >


    --
    Using M2, Opera's revolutionary e-mail client: [url]http://www.opera.com/m2/[/url]
    Bill Priess Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139