BoundField.HtmlEncode プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As BoundField Dim value As Boolean value = instance.HtmlEncode instance.HtmlEncode = value
/** @property */ public boolean get_HtmlEncode () /** @property */ public void set_HtmlEncode (boolean value)
フィールド値を BoundField オブジェクトに表示する前に HTML エンコードする場合は true。それ以外の場合は false。既定値は true です。

フィールド値を BoundField オブジェクトに表示する前に、それぞれの文字列形式に HTML エンコードするかどうかを指定するには、HtmlEncode プロパティを使用します。
![]() |
---|
HTML エンコーディング フィールドの値を使用すると、クロスサイト スクリプト攻撃や悪意のある内容の表示を防止できます。可能な場合は必ずこのプロパティを有効にしてください。 |

HtmlEncode プロパティを使用して、フィールド値を BoundField オブジェクトに表示する前にそのフィールド値の HTML エンコードを防止するコード例を次に示します。
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" allowpaging="true" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" htmlencode="false" headertext="Customer Name"/> <asp:boundfield datafield="Address" htmlencode="false" headertext="Address"/> <asp:boundfield datafield="City" htmlencode="false" headertext="City"/> <asp:boundfield datafield="PostalCode" htmlencode="false" headertext="ZIP Code"/> <asp:boundfield datafield="Country" htmlencode="false" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" allowpaging="true" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" htmlencode="false" headertext="Customer Name"/> <asp:boundfield datafield="Address" htmlencode="false" headertext="Address"/> <asp:boundfield datafield="City" htmlencode="false" headertext="City"/> <asp:boundfield datafield="PostalCode" htmlencode="false" headertext="ZIP Code"/> <asp:boundfield datafield="Country" htmlencode="false" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBoundField.HtmlEncode プロパティを検索する場合は、下記のリンクをクリックしてください。

- BoundField.HtmlEncode プロパティのページへのリンク