Solved

add a key to user registration for validation

Posted on 2010-09-10
5
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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