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
Solved

add a key to user registration for validation

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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