Solved

add a key to user registration for validation

Posted on 2010-09-10
5
432 Views
Last Modified: 2012-05-10
I am integrating a key/paraphase into the .net create user membership registeration page. I got everything connected however I cant seem to stop the creation of the user. When the key is invalid, I exit the sub and it still creates the user. I cant seem to stop it from creating the user even when the key is invalid.

Protected Sub CreateUserWizard2_CreatedUser(ByVal sender as object, ByVal e as eventargs) handles CreateUserWizard2.CreatedUser
Dim Flag as boolean
Flag=false

If Flag=false then
lblmessage2.Text="INVALID"
Exit Sub
Else
Create()
End If
End Sub
0
Comment
Question by:Ryla
5 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 33650211
handles CreateUserWizard2.CreatedUser

From the looks of it CreatedUser happens after the fact.  I think you want to trap on the submit.

Instead of exit sub, can you call a delete user to remove the newly created user?
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33650212
The event you called is CreatedUser, which means the event will fire after the user has already been created.

Change this to an event before creating user or in the middle of creating user, like CreateUser or CreatingUser.
0
 
LVL 30

Expert Comment

by:MlandaT
ID: 33650597
http://msdn.microsoft.com/en-us/library/txa0s749.aspx

You are using the wrong event... use the CreatingUser event:
Set "e.Cancel = true" if you dont want to create the user.

     If Not IsValidEmail(Login1.UserName) Then
           message = "You must enter a valid e-mail address."
            e.Cancel = True
        Else
            message = String.Empty
        End If
0
 
LVL 30

Accepted Solution

by:
MlandaT earned 500 total points
ID: 33650616
More complete:
Sub Createuserwizard2_CreatingUser(ByVal sender As Object, ByVal e As LoginCancelEventArgs) Handles Createuserwizard2.CreatingUser
       If Not IsValidEmail(Createuserwizard2.UserName) Then
           message = "You must enter a valid e-mail address."
            e.Cancel = True
        Else
            message = String.Empty
        End If
End Sub

Open in new window

0
 

Author Closing Comment

by:Ryla
ID: 33652054
Thank you so much!! You saved me from a headache!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question