DetailsView.Caption プロパティ

定義

DetailsView コントロールの HTML キャプション要素に表示するテキストを取得または設定します。 このプロパティは、補助技術デバイスのユーザーにとって、より使いやすいコントロールを実現するための手段として用意されています。

public:
 virtual property System::String ^ Caption { System::String ^ get(); void set(System::String ^ value); };
public virtual string Caption { get; set; }
member this.Caption : string with get, set
Public Overridable Property Caption As String

プロパティ値

DetailsView コントロールの HTML キャプション要素に表示されるテキストを表す文字列。 既定値は空の文字列 ("") です。

次のコード例では、 プロパティを Caption 使用して、コントロールにレンダリングされる HTML キャプション要素のテキストを指定する方法を DetailsView 示します。


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView Caption and CaptionAlign Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          caption="Customer Details"
          captionalign="Left"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID], 
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] 
            From [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView Caption and CaptionAlign Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          caption="Customer Details"
          captionalign="Left"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID], 
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] 
            From [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

注釈

コントロール内の Caption HTML キャプション要素でレンダリングするテキストを指定するには、 プロパティを DetailsView 使用します。 指定するテキストは、支援技術デバイスに、コントロールのアクセシビリティを高めるために使用できるテーブルの説明を提供します。

コントロールの DetailsView 追加のアクセシビリティサポートは、 プロパティによって CaptionAlign 提供されます。 コントロール内の CaptionAlign HTML キャプション要素の配置を指定するには、 プロパティを DetailsView 使用します。

Caption 値はビュー ステートに格納されます。

このプロパティの値を設定すると、デザイナー ツールを使用してリソース ファイルに自動的に保存できます。 詳細については、「グローバリゼーションとローカライズ」を参照してくださいLocalizableAttribute

適用対象

こちらもご覧ください