Possible XHTML bug with <asp:Table> tag and HorizontalAlign property

Discussion in 'ASP .Net' started by Mark Rae, Nov 5, 2006.

  1. Mark Rae

    Mark Rae Guest

    Hi,

    Consider the following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    ....
    ....
    ....
    <asp:panel ID="pnlCart" Runat="server" HorizontalAlign="Center">
    <asp:Table HorizontalAlign="Center" ID="tblCart" Runat="server"
    BorderColor="White" BorderStyle="Solid" BorderWidth="1" GridLines="Both">
    <asp:TableRow>
    ...
    </asp:TableRow>
    <asp:TableRow>
    ...
    </asp:TableRow>
    <asp:TableRow>
    ...
    </asp:TableRow>
    <asp:Table>
    <asp:panel>

    That produces the following HTML:

    <div id="pnlCart" style="text-align:center;">
    <table id="tblCart" align="Center" rules="all" border="1"
    style="border-color:White;border-width:1px;border-style:Solid;">
    <tr>
    ....
    </tr>
    <tr>
    ....
    </tr>
    <tr>
    ....
    </tr>
    </table>
    </div>

    This fails validation through http://validator.w3.org/ because of the
    capitalisation of "Center" in align="Center". Even changing the <asp:Table
    tag to spell it with a lower-case "c" i.e. HorizontalAlign="center" still
    renders the HTML with a capital "C".

    I don't want to use a textalign style, as that will center all the text
    within the individual tablecells.

    Has anyone else noticed this? Is there a way round it to pass XHTML
    validation?

    Any assistance gratefully received.

    Mark
     
    Mark Rae, Nov 5, 2006
    #1
    1. Advertising

  2. Mark,

    Did you try simple

    tblCart.Attributes["align"]="center"; ?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "Mark Rae" <> wrote in message
    news:...
    > Hi,
    >
    > Consider the following:
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    > ...
    > ...
    > ...
    > <asp:panel ID="pnlCart" Runat="server" HorizontalAlign="Center">
    > <asp:Table HorizontalAlign="Center" ID="tblCart" Runat="server"
    > BorderColor="White" BorderStyle="Solid" BorderWidth="1" GridLines="Both">
    > <asp:TableRow>
    > ...
    > </asp:TableRow>
    > <asp:TableRow>
    > ...
    > </asp:TableRow>
    > <asp:TableRow>
    > ...
    > </asp:TableRow>
    > <asp:Table>
    > <asp:panel>
    >
    > That produces the following HTML:
    >
    > <div id="pnlCart" style="text-align:center;">
    > <table id="tblCart" align="Center" rules="all" border="1"
    > style="border-color:White;border-width:1px;border-style:Solid;">
    > <tr>
    > ...
    > </tr>
    > <tr>
    > ...
    > </tr>
    > <tr>
    > ...
    > </tr>
    > </table>
    > </div>
    >
    > This fails validation through http://validator.w3.org/ because of the
    > capitalisation of "Center" in align="Center". Even changing the <asp:Table
    > tag to spell it with a lower-case "c" i.e. HorizontalAlign="center" still
    > renders the HTML with a capital "C".
    >
    > I don't want to use a textalign style, as that will center all the text
    > within the individual tablecells.
    >
    > Has anyone else noticed this? Is there a way round it to pass XHTML
    > validation?
    >
    > Any assistance gratefully received.
    >
    > Mark
    >
     
    Eliyahu Goldin, Nov 5, 2006
    #2
    1. Advertising

  3. Mark Rae

    Mark Rae Guest

    "Eliyahu Goldin" <> wrote in
    message news:...

    > Did you try simple
    >
    > tblCart.Attributes["align"]="center"; ?


    LOL! Yes, of course - but that's hardly the point!
     
    Mark Rae, Nov 5, 2006
    #3
  4. The point is that it could be a work-around, one of the things you've asked
    for. Does it work or no?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "Mark Rae" <> wrote in message
    news:%23nZ%...
    > "Eliyahu Goldin" <> wrote in
    > message news:...
    >
    >> Did you try simple
    >>
    >> tblCart.Attributes["align"]="center"; ?

    >
    > LOL! Yes, of course - but that's hardly the point!
    >
     
    Eliyahu Goldin, Nov 5, 2006
    #4
  5. Mark Rae

    Mark Rae Guest

    "Eliyahu Goldin" <> wrote in
    message news:%...

    > The point is that it could be a work-around, one of the things you've
    > asked for.


    OK, I'm sorry - I didn't phrase my question clearly enough.

    I was asking if the fact that the HorizontalAlign attribute of the
    <asp:Table> tag generates non-compliant XHTML markup was a bug or not, and
    if there was any way of persuading the <asp:Table> tag to generate
    XHTML-compliant markup when using the HorizontalAlign tag.

    > Does it work or no?


    Yes of course it does.
     
    Mark Rae, Nov 5, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    961
    John C. Bollinger
    Jan 27, 2006
  2. Rio
    Replies:
    4
    Views:
    1,249
  3. tshad
    Replies:
    1
    Views:
    5,800
    Christopher Reed
    Jul 27, 2006
  4. Amil Hanish
    Replies:
    0
    Views:
    384
    Amil Hanish
    Mar 12, 2007
  5. Replies:
    2
    Views:
    552
    Bergamot
    Jul 25, 2007
Loading...

Share This Page