Solved

add a key to user registration for validation

Posted on 2010-09-10
5
428 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 39

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now