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

Here's the signup.aspx page:

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

<%@ 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 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">
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">

<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'); = 'hidden'; = '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) { = result ? 'visible' : 'hidden';

Here's the Signup.cs file:
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
public static bool UserNameExists(string yourName)
return Membership.GetUser(yourName) != null;


Reply With Quote