Share via


PasswordRecovery.UserNameRequiredErrorMessage 屬性

定義

取得或設定要在使用者將 [使用者名稱] 文字方塊留為空白時顯示的錯誤訊息。

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

屬性值

String

當 [使用者名稱] 文字方塊為空白時顯示的錯誤訊息。 預設值為 [使用者名稱]。

範例

下列程式碼範例會 UserNameRequiredErrorMessage 變更密碼復原頁面上控制項中顯示的 ValidationSummary 屬性。

<%@ 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>
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <p>
      <asp:PasswordRecovery id="PasswordRecovery1" runat="server" 
        AnswerRequiredErrorMessage="You must enter an answer." 
        UserNameRequiredErrorMessage="You must enter a user name.">
      </asp:PasswordRecovery>
    </p>
    <p>
      <asp:ValidationSummary id="ValidationSummary1" runat="server">
      </asp:ValidationSummary>
    </p>
 </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>
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <p>
      <asp:PasswordRecovery id="PasswordRecovery1" runat="server" 
        AnswerRequiredErrorMessage="You must enter an answer." 
        UserNameRequiredErrorMessage="You must enter a user name.">
      </asp:PasswordRecovery>
    </p>
    <p>
      <asp:ValidationSummary id="ValidationSummary1" runat="server">
      </asp:ValidationSummary>
    </p>
 </form>
</body>
</html>

備註

UserNameRequiredErrorMessage屬性包含錯誤訊息,顯示在與控制項相同頁面上 PasswordRecovery 的任何 ValidationSummary 控制項中。

屬性的預設文字會根據伺服器的地區設定進行當地語系化。

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

適用於

另請參閱