By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Which ASP.NET Controls Have Child Controls?

P: n/a
poi


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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <dd*****@rucs.nul> wrote in message
news:%2****************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #2

P: n/a
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
http://www.takempis.com
Complex things are made up of
lots of simple things.

"poi" <dd*****@rucs.nul> wrote in message
news:%2****************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3

P: n/a
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 <dd*****@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.