 |
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
 | This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

January 15th, 2010, 01:40 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Create user wizard-check existing user
Hello Sir,
well I was busy in my exams that's why I couldn't complete some tasks.
I had already discussed the topic but that was not complete and messed up with other posts just because of me. But now I will stick to only the relevant topic.
The problem was that while creating user account everything goes well except that it pops up the message like
Code:
usernameRequiredMessage is null or not an object
You replied earlier in this thread (Post No. 6 & 7). there you suggested to look for the html in browser.
The html is as follows (just posting required message)
Code:
<td>
<label for="ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserName" id="ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserNameLabel">
User Name:</label>
</td>
<td>
<input name="ctl00$ContentPlaceHolder1$CreateUserWizard1$CreateUserStepContainer$UserName" type="text" id="ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserName" />
<span id="ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserNameRequired" title="User Name is required." style="color:Red;visibility:hidden;">*</span> </td>
<script type="text/javascript">
var userNameTextBox = $get('ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserName');
var userNameRequiredMessage = $get('ctl00_ContentPlaceHolder1_CreateUserWizard1_CreateUserStepContainer_UserNameRequired'); var errorMessage = document.createElement('span');
errorMessage.style.visibility = 'hidden';
errorMessage.style.color = 'red';
errorMessage.innerText = 'Sorry; User Name Already Exist, Try Another Name'; userNameRequiredMessage.insertBefore(errorMessage);
function UserNameExists()
{
var userName = userNameTextBox.value;
PageMethods.UserNameExists(userName, UserNameExistsCallback);
}
function UserNameExistsCallback(result)
{
errorMessage.style.visibility = result ? 'visible' : 'hidden';
}
$addHandler(userNameTextBox, 'blur', UserNameExists);
</script>
well I have looked at the html and seems quite right. But can you please spot out the error that I can not see.
Hope this time I'll get rid off this error.
Thank you sir...
Last edited by sophia; January 15th, 2010 at 01:44 PM..
|
|

January 15th, 2010, 05:52 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you post the code for the page itself? And do you have a ScriptManager on the page?
Also, can you make this work with the download that comes with my article? If it does, check your source for any differences...
Imar
|
|

January 16th, 2010, 01:03 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Thank you sir for having a look on problem.
The Page contains the master page and there is the Script Manager, which has EnablePageMethod set to True
The mark up for the page is
Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="false" CodeFile="sign_up.aspx.vb" Inherits="sign_up" title="Sign Up" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="content">
<div class="post">
<h2 class="title">Hi Guys, Just Fill In Form And Enjoy..............</h2>
<div class="entry">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
style="top: 392px; left: 340px; position: absolute; height: 294px; width: 328px"
CreateUserButtonText="Sign Me Up"
ContinueDestinationPageUrl="~/login.aspx"
EditProfileText="Edit Your Record" EditProfileUrl="~/sign_up.aspx"
EmailRegularExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
EmailRegularExpressionErrorMessage="Please Enter Email In Proper Format" Font-Italic="True"
EmailLabelText="E-mail (Genuine):"
InvalidPasswordErrorMessage="Password Length Should Be Minimum Of {0} Characters.">
<CreateUserButtonStyle ForeColor="#39561D" Font-Bold="True"
Font-Italic="True" />
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" />
</WizardSteps>
</asp:CreateUserWizard>
<script type="text/javascript">
var userNameTextBox = $get('<%= CreateUserWizard1.ClientID %>_CreateUserStepContainer_UserName')
var userNameRequiredMessage = $get('<%= CreateUserWizard1.ClientID %>_CreateUserStepContainer_UserNameRequired')
var errorMessage = document.createElement('span')
errorMessage.style.visibility = 'hidden'
errorMessage.style.color = 'red'
errorMessage.innerText = 'Sorry; User Name Already Exist, Try Another Name'
userNameRequiredMessage.insertBefore(errorMessage)
function UserNameExists()
{
var userName = userNameTextBox.value
PageMethods.UserNameExists(userName, UserNameExistsCallback)
}
function UserNameExistsCallback(result)
{
errorMessage.style.visibility = result ? 'visible' : 'hidden'
}
$addHandler(userNameTextBox, 'blur', UserNameExists)
</script>
</div>
</div>
</div>
</asp:Content>
And the code behind file is
Code:
Imports System.Web.Services
Imports System.Web.Security
Partial Class sign_up
Inherits System.Web.UI.Page
<WebMethod()> _
Public Shared Function UserNameExists(ByVal yourName As String) As Boolean
Return Membership.GetUser(yourName) IsNot Nothing
End Function
End Class
I am astonished; I did try with the download that came with your article, it reports the same message there also.
Now what should I do. Please have a time to check the code as it is getting problem. How it can be removed.
Thank you sir...
Last edited by sophia; January 16th, 2010 at 01:32 PM..
|
|

January 16th, 2010, 01:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It runs fine for me, so it must be something in your site or configuration. Did youy try my sample site as is, in a new web site project?
How does the membership definition in web.config look?
Imar
|
|

January 17th, 2010, 07:09 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Sir,
I have tried the code in a brand new web site project but same error persists.
And the Membership definition in the web.config file is as follows
Code:
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
I have done same as in the article.
Please throw some light on the topic.
Thank you...
|
|

January 17th, 2010, 07:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
Please throw some light on the topic.
|
I can't, as I don't know what's wrong. Somehow, you don't have the correct client side elements in your page. You'll need to do some JavaScript and HTML debugging to see what's wrong.
Imar
|
|

January 17th, 2010, 07:24 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Quote:
|
Somehow, you don't have the correct client side elements in your page. You'll need to do some JavaScript and HTML debugging to see what's wrong.
|
Can you please specify what are these client side elements? And thanks for giving hint of using debugging.
Thank you...
|
|

January 17th, 2010, 07:29 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The HTML elements that the JavaScript is looking for:
This:
var userNameTextBox = $get('ctl00_ContentPlaceHolder1_CreateUserWizard1_ CreateUserStepContainer_UserName');
gets a reference to an HTML element with an id of ctl00_ContentPlaceHolder1_CreateUserWizard1_Create UserStepContainer_UserName.
Since the error you get says some object is null, the right HTML may not be present.
Maybe you're not using ASP.NET 3.5? Maybe your AJAX framework in .NET 2 has not been set up correctly? (Please don't ask me how to that, as that is well, well, well beyond the scope of this book, my article and this forum. Check www.asp.net instead).
Cheers,
Imar
|
|

January 17th, 2010, 07:37 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
thanks for having look on the topic.
And I will try at the link you specified. Well I am using ASP.NET 3.5
Again thank you for that.
keep smiling 
|
|
 |