DetailsView.Caption Proprietà

Definizione

Ottiene o imposta il testo di cui eseguire il rendering in un elemento didascalia HTML in un controllo DetailsView. Questa proprietà viene fornita per rendere il controllo più accessibile agli utenti di dispositivi che assistono i disabili.

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

Valore della proprietà

Una stringa che rappresenta il testo di cui eseguire il rendering in un elemento didascalia HTML in un controllo DetailsView. Il valore predefinito è una stringa vuota ("").

Esempio

Nell'esempio di codice seguente viene illustrato come utilizzare la Caption proprietà per specificare il testo per l'elemento didascalia HTML di cui viene eseguito il rendering in un DetailsView controllo .


<%@ 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>

Commenti

Utilizzare la Caption proprietà per specificare il testo di cui eseguire il rendering in un elemento didascalia HTML in un DetailsView controllo . Il testo specificato fornisce dispositivi di assistive technology con una descrizione della tabella che può essere usata per rendere il controllo più accessibile.

Il supporto aggiuntivo per l'accessibilità per il DetailsView controllo viene fornito dalla CaptionAlign proprietà . Utilizzare la CaptionAlign proprietà per specificare l'allineamento dell'elemento didascalia HTML in un DetailsView controllo .

Il valore di viene archiviato nello stato di Caption visualizzazione.

Il valore di questa proprietà, se impostato, può essere salvato automaticamente in un file di risorse usando uno strumento di progettazione. Per altre informazioni, vedere LocalizableAttribute Globalizzazione e localizzazione.

Si applica a

Vedi anche