語言

PasswordRecovery.AnswerRequiredErrorMessage 屬性

定義

當答案文字框為空白時,會接收或設定顯示給使用者的錯誤訊息。

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

屬性值

錯誤訊息會在回答文字框為空時顯示。 預設是「答案」。

範例

以下程式碼範例變更 AnswerRequiredErrorMessage 了頁面控制項中顯示的 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>

備註

包含 AnswerRequiredErrorMessage 錯誤訊息,需在任何 ValidationSummary 控制項中顯示於與控制 PasswordRecovery 項同一頁面。

該屬性的預設文字會根據伺服器的區域設定在地化。

設定後,該屬性的值可透過設計工具自動儲存到資源檔案中。 欲了解更多資訊,請參閱LocalizableAttribute全球化與在地化。

適用於

另請參閱