HTML表格无法在IE9中正确呈现 [英] HTML table not rendering correctly in IE9

查看:120
本文介绍了HTML表格无法在IE9中正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常奇怪,这个。

我正在使用 asp:Repeater 来创建HTML表格,如下:

I'm using an asp:Repeater to create an HTML table, like so:

加价:

<asp:Repeater ID="myRpt" runat="server">
    <HeaderTemplate>
        <table id="myGrd" border="0" style="cursor:pointer;width:100%;  background-color:white;" cellpadding="2" cellspacing="0">
            <tbody>
    </HeaderTemplate>
    <ItemTemplate>
        <tr onclick="criteria.rowClicked(this);">
            <td style="border:solid 1px black;">
                <asp:Literal ID="lblName" runat="server"></asp:Literal>
            </td>
            <td style="border:solid 1px black;width:200px;">
                <asp:Literal ID="lblRange" runat="server"></asp:Literal>
            </td>

            <td style="display:none;" >
                <asp:Literal ID="lblMisc" runat="server"></asp:Literal>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </tbody> </table>
    </FooterTemplate>
</asp:Repeater>

VB:

    Public Sub populateGrid(ByVal ds As DataSet)
        'ds is just made from a simple select query
        myRpt.DataSource = ds
        myRpt.DataBind()
    End Sub

 Private Sub myRpt_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles myRpt.ItemDataBound
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim lblName As Literal = e.Item.FindControl("lblName")
            Dim lblRange As Literal = e.Item.FindControl("lblRange")
            Dim lblMisc As Literal = e.Item.FindControl("lblMisc")

            lblName.Text = "<font style='font-size:10pt; font-family:arial;'>" & Trim(e.Item.DataItem("Name")) & "</font>"
            lblRange.Text = "<font style='font-size:10pt; font-family:arial;'>" & Trim(e.Item.DataItem("Range")) & "</font>"
            lblMisc.Text = "<font style='font-size:10pt; font-family:arial;'>" & Trim(e.Item.DataItem("Miscellaneous")) & "</font>"
        End If
    End Sub

这在Firefox和Chrome中显示正常,以及大多数时候在IE浏览器中。但是有时对于较大的表(50多行),IE表现得很奇怪。它似乎添加了一个空格...

This displays fine in Firefox and Chrome, and most of the time in IE. However sometimes for larger tables (50+ rows) IE behaves strangely. It appears to add a blank cell...

...但HTML中没有任何内容 - 我使用开发人员工具检查过。不正确的行与正确的行具有相同的标记,但单元格文本除外。更重要的是,如果我删除了不正确的行,那么它上面的那一行就开始显示错误了。

...but there's nothing in the HTML- I've checked using the developer tools. The incorrect row has identical markup to the correct rows, except for the cell text. Whatsmore, if I delete the incorrect row, the one above it starts displaying wrong instead.

请问有人可以建议为什么地球上IE正在渲染它,这就是我可以做到阻止它。

Please can someone suggest why on earth IE is rendering it like this, and what I can do to stop it.

推荐答案

这似乎是IE9渲染大型表时的一个已知错误。在删除表格def开始和结束标记之间的空白时,问题得到解决,例如。 < / td>< td>

This seems to be a known bug with IE9 on rendering large tables. The problem was resolved when removing white space between table def opening and closing tags eg. </td><td>

关于IE 9渲染的MSDN讨论

这篇关于HTML表格无法在IE9中正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆