asp:panel, should not produce html!

  • Thread starter Thread starter Fraggle
  • Start date Start date
F

Fraggle

If I put the following in my code

<asp:panel runat="server" visible="true" id="foo" >

</asp:panel>


I get this as html back; this is using the lovely Mozilla

<table id="_ctl1_foo" cellpadding="0" cellspacing="0" border="0"
width="100%"><tbody><tr><td>



</td></tr></tbody></table>

Using IE i get the less horrid

<div id="_ctl1_foo">

</div>

But really I don't want any actual html from a panel, I just want it
to show and hide the contents! I can do the layout myself.

I have full power over the server, so if I must mess around in there
then I will!

Cheers

Fragg
 
it has to produce html....how else will it wrap a hide/show around the
content?
 
Curt_C said:
it has to produce html....how else will it wrap a hide/show around the
content?

Why does it? all the hide/show stuff is done server side. Only the
server needs to know where the tags are, and which are set to display.

Someone suggested using placeholders, but I don't see the similarity.
I can wrap arbitrary code in a panel, but a placeholder I would need
to build up with hundreds of 'new literalcontrol ("<td>")' statements,
making my code many times more unreadable and harder to maintain.
 
Someone suggested using placeholders, but I don't see the similarity.
I can wrap arbitrary code in a panel, but a placeholder I would need
to build up with hundreds of 'new literalcontrol ("<td>")' statements,
making my code many times more unreadable and harder to maintain.

Incorrect. a PlaceHolder Control has a Controls collection, just like any
other System.Web.UI.Control (Controls is a member of the Base class).
Therefore, you can add Controls to it just like any other Control. In fact,
from what you described in your message, you're already doing so with
LiteralControls. If you want, you can add an HtmlTable Control, a DataGrid,
Repeater, User Control, or any other Control to it. If you are putting a lot
of hand-coded HTML into it, consider using a custom User Control for the
HTML and adding that to the PlaceHolder.

The ONLY difference is that it doesn't render any HTML of its own. Think of
a PlaceHolder as a Panel without the div, if it makes it easier for you.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top