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全球化和本地化

适用于

另请参阅