ASP.NET 4在IIS7和IIS6中以不同方式发布HTML - 是否有修复?

时间:2013-05-31 18:13:55

标签: asp.net iis-6 iis-7.5

我们的应用程序中的一个页面使用GridView进行显示 - 它以表格的形式发出。我们更喜欢离开边界,因此这些被编码为被抑制。看到这段代码:

<asp:GridView CssClass="detail" AutoGenerateColumns="false" UseAccessibleHeader="true" RowStyle-CssClass="detail_data" BorderWidth="0" HeaderStyle-CssClass="detail_label" runat="server" ID="RiembursementRequestGrid">
    <Columns>
        <asp:BoundField HeaderStyle-Wrap="false" HeaderText="RR Id" DataField="RR ID" />
        <asp:BoundField HeaderText="Official Station" DataField="Official Station" />
        <asp:BoundField HeaderText="Official Residence" DataField="Official Residence" />
        <asp:BoundField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Description" DataField="Description" />
        <asp:BoundField HeaderText="Routing Status" DataField="Routing Status" />
        <asp:BoundField HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderText="Amount Requested" DataField="Amount Requested" DataFormatString="{0:c}" HtmlEncode="false" />
        <asp:BoundField HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderText="Taxable Amount" DataField="Taxable Amount" DataFormatString="{0:c}" HtmlEncode="false" />
        <asp:BoundField HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderText="Travel Advance" DataField="Travel Advance" DataFormatString="{0:c}" HtmlEncode="false" />
    </Columns>              
</asp:GridView> 

相关的CSS课程项目是:

.detail
{
    border: none;
    width: 100%;
    font-weight: bold;
    text-align: center;
    font-family: "Arial";
    empty-cells: show;
    border-collapse: collapse;
}
.detail_data
{
    border: none;
    text-align: center;
    font-size: small;
    font-weight: normal;
    border-collapse: collapse;
}
.detail_label
{
    border: none;
    text-align: center;
    font-size: small;
    font-weight: bold;
    border-collapse: collapse;
}

工作站发出的内容与服务器发出的内容之间存在差异。

在我的开发工作站上,运行IIS7.5的Win7,边框正确缺席。在运行IIS6的Win2003服务器上,存在边框。这与完全相同的代码和CSS,以及查看它的相同浏览器。这是比较截图:

Screenshot comparison

正在发出的代码存在差异。这是运行IIS7.5的工作站上的表开始标记的HTML代码:

<table class="detail" cellspacing="0" rules="all" border="0" id="RiembursementRequestGrid" style="border-width:0px;border-collapse:collapse;">

在运行IIS6的服务器上

<table class="detail" cellspacing="0" rules="all" id="RiembursementRequestGrid" style="border-width:0px;border-collapse:collapse;">

如您所见,唯一的区别是一个标签省略了 border =“0”。对于那个边界真的缺失了。我原以为“border-width:0”会涵盖那个特定的基础。

请注意,除了开始表标记之外,所有其他发出的HTML(viewstate值除外)都是相同的。

问题是:

  • 这是否与IIS版本之间的差异真正相关
  • 你会如何解决它?

1 个答案:

答案 0 :(得分:1)

您是否尝试过使用web.config中的controlRenderingCompatibilityVersion设置?

如果设置为3.5或更高,则tableimageimagebutton标记将省略边框值。

详细信息:http://www.asp.net/whitepapers/aspnet4/breaking-changes

相关问题