Share via


FormView.CaptionAlign 屬性

定義

取得或設定 FormView 控制項中 HTML 標題項目的水平或垂直位置。 這個屬性可讓協助技術裝置的使用者更容易存取控制項。

public:
 virtual property System::Web::UI::WebControls::TableCaptionAlign CaptionAlign { System::Web::UI::WebControls::TableCaptionAlign get(); void set(System::Web::UI::WebControls::TableCaptionAlign value); };
public virtual System.Web.UI.WebControls.TableCaptionAlign CaptionAlign { get; set; }
member this.CaptionAlign : System.Web.UI.WebControls.TableCaptionAlign with get, set
Public Overridable Property CaptionAlign As TableCaptionAlign

屬性值

其中一個 TableCaptionAlign 值。 預設值為 TableCaptionAlign.NotSet

例外狀況

指定的值不是其中一個 TableCaptionAlign 列舉值。

範例

下列範例示範如何使用 CaptionAlign 屬性來指定控制項中的 FormView HTML 標題專案應該在控制項左側呈現。


<%@ 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>FormView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView Caption and CaptionAlign Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        caption="Employee Details"
        captionalign="Left"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </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>FormView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView Caption and CaptionAlign Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        caption="Employee Details"
        captionalign="Left"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

備註

CaptionAlign使用 屬性可指定 控制項中 FormView HTML 標題元素的水準或垂直位置。 這個屬性可讓協助技術裝置的使用者更容易存取控制項。

這個屬性是使用其中 TableCaptionAlign 一個列舉值來設定。 下表列出可能的值。

描述
TableCaptionAlign.Bottom 標題項目與資料表底端對齊。
TableCaptionAlign.Left 標題項目與資料表左邊對齊。
TableCaptionAlign.NotSet 未設定標題專案的對齊方式。
TableCaptionAlign.Right 標題項目與資料表的右邊對齊。
TableCaptionAlign.Top 標題項目與資料表的頂端對齊。

注意

當這個屬性設定為 TableCaptionAlign.NotSet 時,會使用瀏覽器的預設值。

屬性會 Caption 提供控制項的其他協助工具支援 FormViewCaption使用 屬性來指定要在 控制項的 HTML 標題專案中呈現的 FormView 文字。

適用於

另請參閱