2017年7月8日 星期六

[研究][ASP.NET] GridView 的 BoundField 的 ItemStyle-Wrap 輸出到瀏覽器時被轉譯成甚麼?

[研究][ASP.NET] GridView 的 BoundField 的 ItemStyle-Wrap 輸出到瀏覽器時被轉譯成甚麼?

2017-07-08

Visual Studio 2017 + NET 4.7 + WebForm

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication7.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT * FROM [Table3]"></asp:SqlDataSource>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="no" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="no" HeaderText="no" InsertVisible="False" ReadOnly="True" SortExpression="no" />
                <asp:BoundField DataField="C1" HeaderText="C1" SortExpression="C1" ItemStyle-Wrap="false" />
                <asp:BoundField DataField="C2" HeaderText="C2" SortExpression="C2" ItemStyle-Wrap="true" />
            </Columns>
        </asp:GridView>
    </form>
</body>
</html>


Windows 7 + IE11 看到


ItemStyle-Wrap="true" 是預設值,不過連續的1是當成1個數字,HTML不會從中間斷行。

ItemStyle-Wrap="false" 不是預設值,被翻譯成為  style="white-space:nowrap;"


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>

</title></head>
<body>
    <form method="post" action="./Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="WmyD9rcUuCmJul+JaqfTUl+fBKKU/WNkJv1OnxgvoWHv2QpBGQcDaVWUEbRTDlvZHAugFvrhHDMDfOPuhaJz18rseygHtSUY7t6pmWI5AgdX/19fUR6aQZ4OIX8VLkbWaTrXmZ+UECqgFDPi0jp8FZoOTXpHhDZnv56PNYdqyjw9hjlJs2yNjdcZckQxP1NfnHE2L3/as0f/2JvAaMMOzeIfPwKT3DSCr8eopXlVoyVE/zQqq8AFGThzPOIfh6/+KT4s+M2v/mK1R5urOrXcg712YwiBqpYriswA6iL0GYZL7Z1axNwgZPppnsaVPNg5l1YpHpHxYqKHRSUC5X++5aEeCjk3HwrFM78+Zma3LE4buA5BLjNhFTeeRDvnyZB1JcIOH3II/poPgEd/cIh4UdPWcMzholxMnk0Y+Ghl5UKzuDlKlYckwXm7DCBbnfscCkM0dAFqXvtSrpbBXQATdQ+g4+1eWoSsL+drZc2optOX+DaCwMnFdSsg6DBvgHruMeu2YmpmUQrF3BL0PIuMGLniMVkzxO60a9prH1+3TfJ63JMDJ5NgibfooMGfviCqqU8fbjaG+E+30zvjqiTVI3xLvS2IADdKJeO3m9eCn+RMpxj21v1XbaZkYTS1HYTyv0IhIg7fGY+jy7o6T/taHg==" />
</div>

        
        <div>
<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
<tr>
<th scope="col">no</th><th scope="col">C1</th><th scope="col">C2</th>
</tr><tr>
<td>1</td><td style="white-space:nowrap;">abc</td><td>4444</td>
</tr><tr>
<td>2</td><td style="white-space:nowrap;">ggggg</td><td>11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</td>
</tr>
</table>
</div>
    
<div class="aspNetHidden">

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
<input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
</div></form>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Internet Explorer","requestId":"703f6f42a3414530a1f042f4cd919026"}
</script>
<script type="text/javascript" src="http://localhost:6840/8c50426377d24ac3b48d6272db1f6ea9/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>


(完)

沒有留言:

張貼留言