View Single Post
  #9 (permalink)  
Old February 4th, 2014, 10:21 PM
Tulsi Tulsi is offline
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default

Here's the signup.aspx page:

Error happens on the following line: userNameRequiredMessage.parentNode.appendChild(err orMessage);

Quote:
<%@ Page Title="Sign Up for a New Account at Planet Wrox" Language="C#" MasterPageFile="~/MasterPages/FrontEnd.master" AutoEventWireup="true" CodeFile="Copy of SignUp.aspx.cs" Inherits="SignUp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" ClientIDMode="Static">
<MailDefinition BodyFileName="~/App_Data/SignUpConfirmation.txt"
Subject="Your New Account at PlanetWrox.com">
</MailDefinition>
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="cpClientScript" Runat="Server">
<script type="text/javascript">
var userNameTextBox = $get('UserName');
var userNameRequiredMessage = $get('UserNameRequired');
var errorMessage = document.createElement('span');
errorMessage.style.visibility = 'hidden';
errorMessage.style.color = 'Red';
errorMessage.innerHTML = 'User Name Already Taken';
userNameRequiredMessage.parentNode.appendChild(err orMessage);

$addHandler(userNameTextBox, 'blur', UserNameExists);

function UserNameExists() {
var userName = userNameTextBox.value;
PageMethods.UserNameExists(userName, UserNameExistsCallback);
}

function UserNameExistsCallback(result) {
errorMessage.style.visibility = result ? 'visible' : 'hidden';
}
</script>
</asp:Content>

Here's the Signup.cs file:
Quote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Security;

public partial class SignUp : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

// Check existence of ASP.Net Membership UserName with ASP.NET AJAX
[WebMethod]
public static bool UserNameExists(string yourName)
{
return Membership.GetUser(yourName) != null;
}

}

Thanks,
Tulsi
Reply With Quote