Empty space (or white space) shown in between cells in ajax fetched data fed to table in IE9 browser only,

百般思念 提交于 2019-12-05 05:18:56

dhiraj - There does not seem to be any official statement about this IE9 bug from MS but I have experienced it on more than one occasion. It seems to be related to the whitespace between table rows and cells in the source code and only happens on tables that are rendered in UpdatePanels after an ajax postback. I have found an (ugly) fix for the problem.

If you use a ListView control, you will have the ability to remove the whitespace in your table structure. Unfortunately it makes your source code more unreadable, but it does seem to fix the problem. So, for example, if your original code looked like this:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
    </table>
</LayoutTemplate>
<ItemTemplate>
    <tr>
        <td><%# Eval("field1") %></td>
        <td><%# Eval("field2") %></td>
        <td><%# Eval("field3") %></td>
        <td><%# Eval("field4") %></td>
    </tr>
</ItemTemplate>

Your "fixed" code would need to look like this:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table><asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder></table>
</LayoutTemplate>
<ItemTemplate>
    <tr><td><%# Eval("field1") %></td><td><%# Eval("field2") %></td><td><%# Eval("field3") %></td><td><%# Eval("field4") %></td></tr>
</ItemTemplate>

Hope this helps!

I'd just like to add that i had the exact same problem.

Loading a table in via AJAX resulted in random gaps between TD elements.

Code that rendered this table was:

echo("  <tr>")
echo("      <td>Column1</td>")
echo("      <td>Column2</td>")
echo("      <td>Column3</td>")
echo("      <td>Column4</td>")
echo("      <td>Column5</td>")
echo("  </tr>")

echo() being a simple wrapper for response.write.

As suggested in the comments here, i simply removed the white space on the response as follows:

echo("<tr>")
echo("<td>Column1</td>")
echo("<td>Column2</td>")
echo("<td>Column3</td>")
echo("<td>Column4</td>")
echo("<td>Column5</td>")
echo("</tr>")

This immediately solved the problem, ugly markup but table now renders consistently. Deffo a bug in IE9

Shvarc

Try to place the contents of the tag <td> in tag <div>

I had the same problem. Random spacer between cells in IE9 in an update panel after a postback.

Like others have suggested, remove the spaces between the table cell elements. It's a little ugly but it does seem to work!

from this...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
</tr>

to this...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td>
</tr>

Solved the problem for me! It only seems to be the spacing between the Table Data elements so you don't have to have the whole table row on one line of mark up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!