Login.LoginButtonText 屬性

定義

取得或設定 Login 控制項之登入按鈕的文字。

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

屬性值

用於 Login 控制項之登入按鈕的文字。 預設值為 "Login"。

範例

下列程式碼範例示範屬性中的 LoginButtonText 文字如何受到 屬性的值 LoginButtonType 影響。

重要

此範例包含一個文字方塊,可接受使用者輸入,這是潛在的安全性威脅。 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。

<%@ 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 changeButton_Click(Object sender, EventArgs e) 
    {
      if (ChooseButtonType.SelectedValue == "Button")
      {
        Login1.LoginButtonType = ButtonType.Button;
      }
      if (ChooseButtonType.SelectedValue == "Image")
      {
        Login1.LoginButtonType = ButtonType.Image;
      }
      if (ChooseButtonType.SelectedValue == "Link")
      {
        Login1.LoginButtonType = ButtonType.Link;
      }
      
      Login1.LoginButtonText = Server.HtmlEncode(buttonText.Text);
    }

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
     <form id="form1" runat="server">
       <table>
           <tr>
             <td>Login Button Text:
             </td>
             <td>
               <asp:TextBox id="buttonText" 
                            runat="server"
                            Text="Login"></asp:TextBox>
             </td>
             <td>Button Type:
             </td>
             <td>
               <asp:DropDownList id="ChooseButtonType" 
                                 runat="server">
                 <asp:ListItem value="Button"
                               selected="true"></asp:ListItem>
                 <asp:ListItem value="Image"></asp:ListItem>
                 <asp:ListItem value="Link"></asp:ListItem>
               </asp:DropDownList>
             </td>
             <td>
                        <asp:Button id="changeButton" runat="server" Text="Change" OnClick="changeButton_Click"></asp:Button>
             </td>
           </tr>
           <tr>
             <td colspan="4" 
                 align="center">
             <asp:Login id="Login1" 
                        runat="server" 
                        LoginButtonType="Image" 
                        LoginButtonText="Log in to Web Site."
                        LoginButtonImageUrl="images\login.png">
             </asp:Login>
             </td>
           </tr>
        </table>
     </form>
  </body>
</html>
<%@ Page Language="VB" 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">
    
  Sub changeButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    If (ChooseButtonType.SelectedValue = "Button") Then
      
      Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Button
      
    End If
    
    If (ChooseButtonType.SelectedValue = "Image") Then
      
      Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Image
      
    End If
    If (ChooseButtonType.SelectedValue = "Link") Then
      
      Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Link
      
    End If
    
    Login1.LoginButtonText = Server.HtmlEncode(buttonText.Text)
    
  End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
     <form id="Form1" runat="server">
       <table>
           <tr>
             <td>Login Button Text:
             </td>
             <td>
               <asp:TextBox id="buttonText" 
                            runat="server"
                            Text="Login"></asp:TextBox>
             </td>
             <td>Button Type:
             </td>
             <td>
               <asp:DropDownList id="ChooseButtonType" 
                                 runat="server">
                 <asp:ListItem value="Button"
                               selected="true"></asp:ListItem>
                 <asp:ListItem value="Image"></asp:ListItem>
                 <asp:ListItem value="Link"></asp:ListItem>
               </asp:DropDownList>
             </td>
             <td>
                        <asp:Button id="changeButton" runat="server" Text="Change" OnClick="changeButton_Click"></asp:Button>
             </td>
           </tr>
           <tr>
             <td colspan="4" 
                 align="center">
             <asp:Login id="Login1" 
                        runat="server" 
                        LoginButtonType="Image" 
                        LoginButtonText="Log in to Web Site."
                        LoginButtonImageUrl="images\login.png">
             </asp:Login>
             </td>
           </tr>
        </table>
     </form>
  </body>
</html>

備註

屬性 LoginButtonText 包含控制項登入按鈕所 Login 顯示的文字。 根據 屬性的值 LoginButtonTypeLoginButtonText 屬性可以顯示為按鈕上的文字、顯示為瀏覽器中未轉譯影像或連結文字的影像替代文字。 下表描述不同 LoginButtonTypeLoginButtonText 如何影響 屬性。

LoginButtonType 設定 LoginButtonText如何使用 屬性。
Button 做為按鈕的 Text 屬性。
Image 作為影像的替代文字。
Link 做為連結文字。

控制項的預設文字會依據伺服器目前的地區設定進行當地語系化。

當設定時,此屬性的值可以使用設計工具自動儲存到資源檔。 如需詳細資訊,請參閱 LocalizableAttribute和全球化和當地語系化

適用於

另請參閱