p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 (http://p2p.wrox.com/forumdisplay.php?f=252)
-   -   using create user wizard (http://p2p.wrox.com/showthread.php?t=76818)

sophia October 29th, 2009 05:37 PM

using create user wizard
Hello Imar sir,
Well everything is going well till now. But the other thing that I am trying to look for is that Is there any way to determine that a user already exist or not, without full post back of the page?
That is as soon as we enter the user name it warns immediately if it exists already. I am using VB.NET . One solution that I think of is using web service, if I am right. So can you please tell the exact way or give some suggestion regarding this. Any help is appreciated.
Thank you..............

Imar October 29th, 2009 07:03 PM

Hi there,

Take a look here: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=494


sophia October 30th, 2009 01:48 PM

First of all thank you sir for such a great post.
But I am still having some problem. As I am using VB.NET so accordingly I changed the web service in vb.net and used in code behind file
The web service that I used looks like

Partial Class sign_up
    Inherits System.Web.UI.Page
 <WebMethod()> _
  Public Function UserNameExists(ByVal yourName As String) As Boolean
        Return Membership.GetUser(yourName) IsNot Nothing
    End Function

  Emailing function goes here.............
End Class

And used the code in sign_up.aspx file as mentioned in post.


create user wizard here....................
    <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 = 'User name already taken'

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

      function UserNameExistsCallback(result)
        errorMessage.style.visibility = result ? 'visible' : 'hidden'

      $addHandler(userNameTextBox, 'blur', UserNameExists)

I have used script manager in master page and necessary namespace in code behind file sign_up.aspx.vb
But on running the code it reports an error as PageMethod is not declared. Is there any thing wrong with webservice that I have changed to vb.net or in calling it?
How it can be fixed.....
Thank you once again for such post.

Imar October 30th, 2009 02:03 PM

Hi there,

Page methods need to be marked static (Shared in VB) so you need to add the Shared keyword to the function header:


Public Shared Function UserNameExists(ByVal yourName As String) As Boolean



sophia October 30th, 2009 02:34 PM

Thank You Sir.......
Thank you sir, You are really amazing. Problem got solved at one shot.
I was missing shared keyword. You are really very nice
Thank you once again and for a quick reply...

sophia November 2nd, 2009 02:57 AM

error pops up while signing up
Hello Sir,
I used web service for getting info. that a user already exists or not. It is working fine but while signing up it pops up an error window showing message

'userNameRequiredMessage' is null or not an object

But the signning up process is successful and creates a new account.
After while a debugging window opens showing message like

Breaking on JScript run time error-'userNameRequiredMessage' is null or not an object
And in the debugging editor it highlightes the code


So what should be done with it and how to get rid of it, althogh account is created successfully.

Imar November 3rd, 2009 01:34 PM

Hi there,

Looks the final HTML of your CreateUserWizard doesn't match the code. Take a look at the final HTML in the browser and see what is assigned to userNameRequiredMessage is really pointing to a valid object in the HTML.



sophia November 9th, 2009 03:04 PM

Hello Sir,
First of all sorry I am here after a great time. And Thank you to answer me.
You suggested to look at html code in browser.
That is really massive.
Well The code that is generated is like

<script type="text/javascript">
var PageMethods = function() {
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
PageMethods.prototype = {
_get_path:function() {
 var p = this.get_path();
 if (p) return p;
 else return PageMethods._staticInstance.get_path();},
UserNameExists:function(yourName,succeededCallback, failedCallback, userContext) {
/// <param name="yourName" type="String">System.String</param>
/// <param name="succeededCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="failedCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="userContext" optional="true" mayBeNull="true"></param>
return this._invoke(this._get_path(), 'UserNameExists',false,{yourName:yourName},succeededCallback,failedCallback,userContext); }}
PageMethods._staticInstance = new PageMethods();
PageMethods.set_path = function(value) {
PageMethods._staticInstance.set_path(value); }
PageMethods.get_path = function() {
/// <value type="String" mayBeNull="true">The service url.</value>
return PageMethods._staticInstance.get_path();}
PageMethods.set_timeout = function(value) {
PageMethods._staticInstance.set_timeout(value); }
PageMethods.get_timeout = function() {
/// <value type="Number">The service timeout.</value>
return PageMethods._staticInstance.get_timeout(); }
PageMethods.set_defaultUserContext = function(value) {
PageMethods._staticInstance.set_defaultUserContext(value); }
PageMethods.get_defaultUserContext = function() {
/// <value mayBeNull="true">The service default user context.</value>
return PageMethods._staticInstance.get_defaultUserContext(); }
PageMethods.set_defaultSucceededCallback = function(value) {
 PageMethods._staticInstance.set_defaultSucceededCallback(value); }
PageMethods.get_defaultSucceededCallback = function() {
/// <value type="Function" mayBeNull="true">The service default succeeded callback.</value>
return PageMethods._staticInstance.get_defaultSucceededCallback(); }
PageMethods.set_defaultFailedCallback = function(value) {
PageMethods._staticInstance.set_defaultFailedCallback(value); }
PageMethods.get_defaultFailedCallback = function() {
/// <value type="Function" mayBeNull="true">The service default failed callback.</value>
return PageMethods._staticInstance.get_defaultFailedCallback(); }
PageMethods.UserNameExists= function(yourName,onSuccess,onFailed,userContext) {
/// <param name="yourName" type="String">System.String</param>
/// <param name="succeededCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="failedCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="userContext" optional="true" mayBeNull="true"></param>
PageMethods._staticInstance.UserNameExists(yourName,onSuccess,onFailed,userContext); }

Can you now please tell me where is the problem.
Hope next time this problem be shoted out.

sophia November 9th, 2009 03:09 PM

Sir, when I asked you about web service then the link you provided was of your site . There I noticed one thing that you used captcha. Is it another kind of web service or something else. Can you give just a little bit idea how to implement it.
Thank you........

Imar November 10th, 2009 03:59 AM

You need to look in the HTML (not JavaScript) for an element called userNameRequiredMessage

For the Captcha: check out the text above the comment block / Captcha on my site.



All times are GMT -4. The time now is 09:27 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.