PasswordRecovery.UserNameRequiredErrorMessage 属性
定义
获取或设置在用户将“用户名”文本框保留为空时显示的错误消息。Gets or sets the error message displayed when a user leaves the User Name text box empty.
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
属性值
当“用户名”文本框为空时显示的错误消息。The error message displayed when the User Name text box is empty. 默认值为“用户名”。The default is "User Name".
示例
下面的代码示例更改在 UserNameRequiredErrorMessage ValidationSummary 密码恢复页上的控件中显示的属性。The following code example changes the UserNameRequiredErrorMessage property displayed in the ValidationSummary control on the password recovery page.
<%@ 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属性包含与 ValidationSummary 控件在同一页的任何控件中显示的错误消息 PasswordRecovery 。The UserNameRequiredErrorMessage property contains the error message to display in any ValidationSummary control on the same page as the PasswordRecovery control.
属性的默认文本根据服务器的区域设置进行本地化。The default text for the property is localized based on the server's locale setting.
设置此属性后,可以使用设计器工具自动将此属性的值保存到资源文件中。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 有关详细信息,请参阅 LocalizableAttribute 和 全球化和本地化。For more information, see LocalizableAttribute and Globalization and Localization.