Table border issue

Peter_1985 2,806 Reputation points
2025-01-21T03:55:30.69+00:00

Hi,

What is wrong below? How to correct it?

圖片

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 123.8K Reputation points
    2025-01-21T06:07:16.0566667+00:00

    Use class instead of CssClass in this case.

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. AgaveJoe 30,221 Reputation points
    2025-01-21T11:24:57.7966667+00:00

    Many thanks. How to ensure Labels and Textboxes are all having the proper borders?

    What is a "proper border"?

    1 person found this answer helpful.

  2. MohaNed Ghawar 165 Reputation points
    2025-02-06T15:03:29.0466667+00:00

    there's a syntax error in the table's class attribute. The problem is with ssclass="Rightborders" - it has an extra 's' and incorrect syntax.

    Here's how to correct it:

    <div class="centered">
        <table class="Rightborders">
            <tr>
                <td>
                    <asp:Label ID="lb_name"
                        Text="Name"
                        Width="230px" />
                </td>
            </tr>
        </table>
    </div>
    

    If you want to apply right borders to your table, make sure you also have the corresponding CSS class defined in your stylesheet:

    .Rightborders {
        border-right: 1px solid #000; /* or whatever border style you prefer */
    }
    
    
    1 person found this answer helpful.

  3. Raymond Huynh (WICLOUD CORPORATION) 715 Reputation points Microsoft External Staff
    2025-08-22T09:35:28.3666667+00:00

    Hello Peter_1985, from your latest comments, it looks like the goal is a clean table grid (borders on the cells), and the current problem is that only the first Label/TextBox pair shows borders while the rest don’t, possibly due to a reset like border:0.

    Here’s a focused fix that matches your current need:

    • Put the Label and TextBox in separate cells.
    • Apply borders to the cells (not the controls) and collapse borders.
    • Remove or override any global resets (table, td { border:0; }) that wipe out borders after the first row.
    • Make sure the class is on the HTML table via class="…" (not CssClass, and no typos like ssclass).

    ASPX

    <table class="grid">
    <tr>
    <td><asp:Label ID="lb_name" runat="server" Text="Name" /></td>
    <td><asp:TextBox ID="tb_name" runat="server" /></td>
    </tr>
    <tr>
    <td><asp:Label ID="lb_age" runat="server" Text="Age" /></td>
    <td><asp:TextBox ID="tb_age" runat="server" /></td>
    </tr>
    </table>
    

    CSS

    .grid {
      border-collapse: collapse;
    }
     
    .grid td, .grid th {
      border: 1px solid #000;
      padding: 4px;
    }
     
    /* If you prefer only right borders per cell: */
    .Rightborders { border-collapse: collapse; }
    .Rightborders td, .Rightborders th { border-right: 1px solid #000; }
    

    If borders still appear only on the first row:

    • Inspect a second-row <td> in dev tools and check “Computed” styles to see which rule is overriding the border.
    • Look for a reset (e.g., table, td { border:0; }) and override it with a more specific selector, for example:
    table.grid td { border: 1px solid #000; }
    
    • Use !important only as a last resort:
    .grid td { border: 1px solid #000 !important; }
    

    If you actually want boxes around the controls themselves (not a table grid), then set:

    <asp:Label ... BorderStyle="Solid" BorderColor="LimeGreen" BorderWidth="2" />
    <asp:TextBox ... BorderStyle="Solid" BorderColor="LimeGreen" BorderWidth="2" />
    

    If you can share your ASPX/HTML + CSS (as text), I can point to the exact rule causing the later rows to drop their borders.

    Hope this helps!

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.