Login.TextLayout 属性

定义

指定 Login 控件的每个标签相对于其关联文本框的位置。

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

属性值

LoginTextLayout 枚举值之一。 默认值为 TextOnLeft

例外

所选的值不是 LoginTextLayout 枚举值之一。

示例

下面的代码示例演示如何使用 LoginTextLayout 枚举来设置 TextLayout 控件的 Login 属性。

<%@ Page Language="C#" AutoEventWireup="False" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  void ChangeTextLayout_Click(object sender, EventArgs e)
  {
      if (Login1.TextLayout == LoginTextLayout.TextOnLeft)
      {
          Login1.TextLayout = LoginTextLayout.TextOnTop;
      }
      else
      {
          Login1.TextLayout = LoginTextLayout.TextOnLeft;
      }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TextLayout Example</title>
</head>
<body>
    <form id="Form1" runat="server">
    <h3>TextLayout Example</h3>
    <table style="text-align:center"
        border="1">
        <tr>
          <td align="center">
            <asp:Login id="Login1" 
              runat="server"
              orientation="Vertical" 
              textlayout="TextOnLeft">
            </asp:Login>
          </td>
        </tr>
        <tr>
          <td align="center">
            <asp:Button id="changeTextLayout" 
              runat="Server" 
              text="Change Text Layout" 
              onclick="ChangeTextLayout_Click" >
            </asp:Button> 
          </td>
        </tr>
      </table>
    </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">

<script runat="server">
  
  Sub ChangeTextLayout_Click(sender as Object, e as EventArgs)
    
    If Login1.TextLayout = LoginTextLayout.TextOnLeft Then
      
      Login1.TextLayout = LoginTextLayout.TextOnTop
      
    Else
      
      Login1.TextLayout = LoginTextLayout.TextOnLeft
      
    End If
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TextLayout Example</title>
</head>
<body>
    <form id="Form1" runat="server">
    <h3>TextLayout Example</h3>
    <table style="text-align:center"
        border="1">
        <tr>
          <td align="center">
            <asp:Login id="Login1" 
              runat="server"
              orientation="Vertical" 
              textlayout="TextOnLeft">
            </asp:Login>
          </td>
        </tr>
        <tr>
          <td align="center">
            <asp:Button id="changeTextLayout" 
              runat="Server" 
              text="Change Text Layout" 
              onclick="ChangeTextLayout_Click" >
            </asp:Button> 
          </td>
        </tr>
      </table>
    </form>
  </body>
</html>

注解

可以使用 TextLayout 属性指定标签相对于控件的关联文本框 Login 的位置。 此属性是使用枚举值之一设置的 LoginTextLayout 。 下表列出了可能的值。

LoginTextLayout 值 说明
TextOnLeft 将标签放到关联的文本输入字段的左侧。
TextOnTop 将标签放到关联的文本输入字段的上方。

适用于

另请参阅