?
Solved

add a key to user registration for validation

Posted on 2010-09-10
5
Medium Priority
?
435 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 31

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 31

Accepted Solution

by:
MlandaT earned 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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