<asp:Panels, borders and HTML tables

M

Mark Rae

Hi,

Is there any way to put a border round several rows in a standard HTML table
by surrounding them with an asp:panel (or a client-side <div>)? When I try,
the border doesn't appear, though it does appear if I surround the entire
table with an asp:panel.

E.g. this doesn't show the panel's border:

<table>
<asp:panel ID=pnlPanel Runat=server BorderColor="Black"
BorderStyle="Solid" BorderWidth="2px">
<tr>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</asp:panel>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>

but this does:

<asp:panel ID=pnlPanel Runat=server BorderColor="Black" BorderStyle="Solid"
BorderWidth="2px">
<table>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>
</asp:panel>
 
G

Guest

you should put border on your table cells with your problem. take a look on
"td" styles.
or make something like this
<table>
<tr>
<td colspan=2>
<asp:panel ID=pnlPanel Runat=server BorderColor="Black"
BorderStyle="Solid" BorderWidth="2px">
<table>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>
</asp:panel>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>

my advice is to look at the table styles, too, and put your border on table
and eliminate the <asp:panel>

You should read about table some stuff.
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/table.asp?frame=true

first row on remarks says:
The following tags are valid in table construction: CAPTION, COL, COLGROUP,
TBODY, TD, TFOOT, TH, THEAD, and TR.
sorry to dissapoint you but in this is not put any <asp:panel> or <div>
 
L

Lucifer

Mark, this is because nothing between <table> and <tr> will render.

you could try using css to apply style to the rows so that:

top row has: border top & left and right

middle rows have: border left and right

and botton row has: botton left and right

(might work, havent tried it..)

e.g.

<style>
..topstyle {
border-left: solid 1px black;
border-right: solid 1px black;
border-top: solid 1px black;
}
..middlestyle {
border-left: solid 1px black;
border-right: solid 1px black;
}
..bottomstyle {
border-bottom: solid 1px black;
border-left: solid 1px black;
border-right: solid 1px black;
};
</style>

<table>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
<asp:panel ID=pnlPanel Runat=server BorderColor="Black"
BorderStyle="Solid" BorderWidth="2px">
<tr class=topstyle>
<td>Text</td>
<td>Text</td>
</tr>
<tr class=middlestyle>
<td>Text</td>
<td>Text</td>
</tr>
<tr class=middlestyle>
<td>Text</td>
<td>Text</td>
</tr>
<tr class=bottomstyle>
<td>Text</td>
<td>Text</td>
</tr>
</asp:panel>
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>
 
M

Mark Rae

Thanks for the reply.
you could try using css to apply style to the rows so that:
top row has: border top & left and right
middle rows have: border left and right
and botton row has: botton left and right

Yes - I was hoping to be able to avoid all that HTML, as it will make it
really irritating when adding and/or deleting rows and/or columns...

Looks like I don't have a choice...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top