这是我在这个最伟大的网站上的第一篇文章。
是否有可能从 OnCheckUserName 函数更改 isValid 属性?如果可以,我该怎么做?
实际上在这个例子中有一个使用网络服务的代码块:
<script type="text/javascript">
function OnloginIDValidation(s, e) {
if (e.value.toString().length > 0) {
e.errorText = "UserName is not available";
PageMethods.CheckUserName(e.value.toString(), OnCheckUserName);
}
}
function OnCheckUserName(unavailable) {
if (unavailable == true) {
e.isValid = true;
}
else if (unavailable != true) {
e.isValid = false;
}
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<dx:ASPxTextBox ID="txt_loginID" runat="server" AssociatedControlID="txt_loginID">
<InvalidStyle BackColor="#FFF5F5">
<Border BorderColor="Red" BorderStyle="Solid" BorderWidth="1px" />
</InvalidStyle>
<ClientSideEvents Validation="OnloginIDValidation" />
</dx:ASPxTextBox>
</asp:Content>
[WebMethod]
public static bool CheckUserName(string userName)
{
if (Membership.GetUser(userName) != null)
{
return true;
}
else
{
return false;
}
}
private void ApplyValidationSummarySettings()
{
vsValidationSummary1.RenderMode = (ValidationSummaryRenderMode)Enum.Parse(typeof(ValidationSummaryRenderMode), "BulletedList");
vsValidationSummary1.ShowErrorAsLink = true;
}
private void ApplyEditorsSettings()
{
ASPxEdit[] editors = new ASPxEdit[] {txt_loginID};
foreach (ASPxEdit editor in editors)
{
editor.ValidationSettings.ValidateOnLeave = true;
editor.ValidationSettings.SetFocusOnError = true;
}
}
它不起作用
我希望能帮助我如何解决它。
谢谢