比较验证器无法在密码模式下工作
问题描述:
我有两个文本框(NewPassword
和ConfirmedPassword
)与TextMode=Password
并且比较验证器不检测它们是否不相等。 Page.IsValid
总是如此。如果我从我的文本框中删除密码模式,一切正常,验证器显示消息,他们是不相等的。我怎样才能使这项工作在密码模式?比较验证器无法在密码模式下工作
答
你应该告诉我们你的代码,因为这按预期工作:
<asp:TextBox id="NewPassword" runat="server"
TextMode="Password" />
<asp:TextBox id="ConfirmedPassword" runat="server"
TextMode="Password" />
<asp:CompareValidator id="comparePasswords"
runat="server"
ControlToCompare="NewPassword"
ControlToValidate="ConfirmedPassword"
ErrorMessage="Your passwords do not match up!"
Display="Dynamic" />
也许你已经混了ControlToCompare
和/或ControlToValidate
。
首先,我将ControlToCompare和NewPassword的'ConfirmedPassword'分配给ControlToValidate,现在我改变了它,就像你在例子中写的那样,它的工作原理。我认为每个文本框的分配位置并不重要,如果它们必须相等:D – vanilla161 2012-08-15 00:10:06