【问题标题】:Difference between web controls rendering and html table properties using ASP.NET使用 ASP.NET 呈现 Web 控件和 html 表属性之间的区别
【发布时间】:2011-05-06 02:55:04
【问题描述】:

我正在用 ASP.NET 设计一个网站,我想在其中构建包含一些文本、文本框和验证器的表格。问题是 Firefox 和 IE 中的表格看起来不同。这是一个例子:

http://www.freeimagehosting.net/image.php?224860e266.png

这是 ASP.NET 中的表格代码:

<table align="center" cellpadding="0" cellspacing="1" style="text-align: right; border-collapse: separate;">
    <tr>
        <td>
            Nadawca:
        </td>
        <td>
            <asp:TextBox ID="TextBoxNadawca" runat="server" Width="250px" BorderStyle="none"
                BackColor="#c1ae85"></asp:TextBox>
        </td>
        <td align="left">
            &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Nadawca jest wymagany."
                ControlToValidate="TextBoxNadawca" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Adres e-mail:
        </td>
        <td>
            <asp:TextBox ID="TextBoxMail" runat="server" Width="250px" BorderStyle="none" BackColor="#c1ae85"></asp:TextBox>
        </td>
        <td align="left">
            &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="E-mail jest wymagany."
                ControlToValidate="TextBoxMail" ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBoxMail"
                ErrorMessage="Nieprawidłowy format." ForeColor="Red" Style="position: absolute;
                top: 589px; left: 632px; width: 160px;" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        </td>
    </tr>
    <tr>
        <td>
            Temat:
        </td>
        <td>
            <asp:DropDownList ID="DropDownTemat" runat="server" Style="margin-left: 0px;" Width="250px"
                BorderStyle="none" BackColor="#c1ae85">
                <asp:ListItem>Reklama w serwisie</asp:ListItem>
                <asp:ListItem>Pomysł na rozwój serwisu</asp:ListItem>
                <asp:ListItem>Chcę zostać moderatorem</asp:ListItem>
                <asp:ListItem>Prawa autorskie</asp:ListItem>
                <asp:ListItem>Banicja</asp:ListItem>
                <asp:ListItem>Błąd na stronie</asp:ListItem>
                <asp:ListItem>Inne</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            Treść:
        </td>
        <td>
            <asp:TextBox ID="TextBoxTresc" runat="server" Height="150px" TextMode="MultiLine"
                Width="250px" BorderStyle="none" BackColor="#c1ae85"></asp:TextBox>
        </td>
        <td align="left">
            &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Treść jest wymagana."
                ControlToValidate="TextBoxTresc" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td style="text-align: center;">
            <asp:Button ID="Button1" runat="server" Text="Wyślij" OnClick="Button1_Click" Width="250px"
                BorderStyle="None" BackColor="#c1ae85" />
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td style="text-align: justify">
            <br />
            <asp:Label ID="Label1" runat="server" Width="250px"></asp:Label>
        </td>
    </tr>
</table>

感谢您的建议,
彼得。

【问题讨论】:

  • 看起来有什么不同?你可能有两者的屏幕截图?
  • 您是否尝试将border="0" 作为&lt;table&gt; 标签的属性?
  • 这与 ASP.Net 无关,只是跨浏览器 CSS/显示问题。

标签: css internet-explorer firefox cross-browser


【解决方案1】:

当我删除你的样式代码时

<table align="center" cellpadding="0" cellspacing="1" style="text-align: right; border-collapse: separate;">

<table align="center">

IE、Firefox 和 Chrome 显示相同。因此,如果您想为您的表格设置样式,建议您尝试 CSS

【讨论】:

    【解决方案2】:

    不要在布局中使用表格,使用 CSS。您应该使用表的唯一时间是用于表格数据。通过在此处使用 CSS,您可以省略获得双边框的border-bottom。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-25
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多