It seems that this wizard does not automatically validate an email address. There is a property setting for a regular setting that should accomplish this task but I can't get anything to work there. I've copied a number of regular expression for email
validation from various internet sources, but I always get a runtime exception. It would seem that this is a very common problem and there probably is a simple solution - but, I can't find it!
I assume this property was established as a simple way to address this common need - is there a regular expression that can be plugged into this property that will catch an invalid email address and give the user a change to correct it?
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="EMAIL TEXT ID HERE" ErrorMessage="RegularExpressionValidator"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
Substitute EMAIL TEXT ID HERE with the name of your wizard's email textbox ID.
<asp:createuserwizard id="Createuserwizard1" runat="server" emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"'
emailregularexpressionerrormessage="E-mail address must be in a valid format"> </asp:createuserwizard>
I should also try the suggestion from Olivespike, but I wasn't quite sure where to find "your wizard's
email textbox ID" - I suspect one needs to expand the templates.
Right now things look good - however, I still need to figure out how to deal with the fact that clicking
the create button only clears the email error and does not fire the registration process until clicked again - that is going to cause confusion.
I'm still having a problem. The issue is that I don't use the security questions so the last textbox is for email. The regular expression works great at catching invalid emails. However, the scenario is: the user enters an invalid email address and is
warned with an error message. Then the user corrects the email address and clicks "create user". This causes the error message to disappear but nothing else happens and the user just sits there thinking that "this is taking a really long time - something
must be wrong". Maybe they click "create user" again - maybe not. This is not a good situation.
I've been trying to figure out how to determine that the error was fixed (when the user clicks "create user" and then actually fire the "create user" process. Or, somehow, tell the user that the email is now OK and click "create user" again. I've tried
all the events in my code behind but nothing seems to address this problem. The "createUserError" event does not make sense to me - I never see it fire. The "creating user" does not fire just because the user clicked the button. I really need to know that
the user has clicked this button and then understand if an error is fixed or not. If the error is fixed then how to move on with the actual create user process.
Actually, I'm having a lot of trouble trying to understand the template model as it relates to this problem. I looked at some tutorials but nothing seems to get at this issue.
The problem is that I never see any of these events the first time the user clicks "create user" after he has fixed his email:
ProtectedSub
CreateUserWizard1_CreatingUser(sender AsObject,
e As
System.Web.UI.WebControls.LoginCancelEventArgs)
Handles
CreateUserWizard1.CreatingUser
MsgBox("creating
user")
EndSub
ProtectedSub
CreateUserWizard1_CreatedUser(sender AsObject,
e As
System.EventArgs)
Handles
CreateUserWizard1.CreatedUser
MsgBox("created
user")
EndSub
ProtectedSub
CreateUserWizard1_CreateUserError(sender AsObject,
e As
System.Web.UI.WebControls.CreateUserErrorEventArgs)
Handles
CreateUserWizard1.CreateUserError
MsgBox("creating
user error")
EndSub
I
don't see the first two messages until the user clicks the create user button the second time (if they actually do). And, I never see that third "createUserError" message.
So,
how can I tell that the user clicked that "create user" button for any reason? How can I wire an event just to that button itself?
daveharney
Member
91 Points
43 Posts
create user wizard email validation
Apr 04, 2012 02:44 AM|LINK
Hi,
It seems that this wizard does not automatically validate an email address. There is a property setting for a regular setting that should accomplish this task but I can't get anything to work there. I've copied a number of regular expression for email validation from various internet sources, but I always get a runtime exception. It would seem that this is a very common problem and there probably is a simple solution - but, I can't find it!
I assume this property was established as a simple way to address this common need - is there a regular expression that can be plugged into this property that will catch an invalid email address and give the user a change to correct it?
olivespike
Member
176 Points
63 Posts
Re: create user wizard email validation
Apr 04, 2012 03:02 AM|LINK
Try this expression validator on your aspx page:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="EMAIL TEXT ID HERE" ErrorMessage="RegularExpressionValidator"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
Substitute EMAIL TEXT ID HERE with the name of your wizard's email textbox ID.
pkay
Member
31 Points
26 Posts
Re: create user wizard email validation
Apr 04, 2012 03:16 AM|LINK
Please try this.
<asp:createuserwizard id="Createuserwizard1" runat="server" emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"' emailregularexpressionerrormessage="E-mail address must be in a valid format"> </asp:createuserwizard>
Ref: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.emailregularexpression.aspx
2pac
Participant
1586 Points
269 Posts
Re: create user wizard email validation
Apr 04, 2012 05:26 AM|LINK
Try this expression
Regards,
Jayesh
daveharney
Member
91 Points
43 Posts
Re: create user wizard email validation
Apr 04, 2012 01:17 PM|LINK
Hi,
Thanks to all of you - this is a great forum for help!
I combined two of the suggestions to get this
emailregularexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" emailregularexpressionerrormessage="E-mail address must be in a valid format"
I'm also happy to report that it properly understood somename@wi.rr.com which is sometimes rejected by some validations because of the double periods.
for some reason this one rejected every email address:
emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"'
I should also try the suggestion from Olivespike, but I wasn't quite sure where to find "your wizard's email textbox ID" - I suspect one needs to expand the templates.
Right now things look good - however, I still need to figure out how to deal with the fact that clicking the create button only clears the email error and does not fire the registration process until clicked again - that is going to cause confusion.
Thanks very much
sriramabi
Contributor
4351 Points
1277 Posts
Re: create user wizard email validation
Apr 04, 2012 01:22 PM|LINK
hi
try this code
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
<asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox>
check pls
thank u
daveharney
Member
91 Points
43 Posts
Re: create user wizard email validation
Apr 05, 2012 03:39 AM|LINK
Hi,
I'm still having a problem. The issue is that I don't use the security questions so the last textbox is for email. The regular expression works great at catching invalid emails. However, the scenario is: the user enters an invalid email address and is warned with an error message. Then the user corrects the email address and clicks "create user". This causes the error message to disappear but nothing else happens and the user just sits there thinking that "this is taking a really long time - something must be wrong". Maybe they click "create user" again - maybe not. This is not a good situation.
I've been trying to figure out how to determine that the error was fixed (when the user clicks "create user" and then actually fire the "create user" process. Or, somehow, tell the user that the email is now OK and click "create user" again. I've tried all the events in my code behind but nothing seems to address this problem. The "createUserError" event does not make sense to me - I never see it fire. The "creating user" does not fire just because the user clicked the button. I really need to know that the user has clicked this button and then understand if an error is fixed or not. If the error is fixed then how to move on with the actual create user process.
Actually, I'm having a lot of trouble trying to understand the template model as it relates to this problem. I looked at some tutorials but nothing seems to get at this issue.
2pac
Participant
1586 Points
269 Posts
Re: create user wizard email validation
Apr 05, 2012 03:58 AM|LINK
in "create user" event add this
if(Page.IsValid) { //implement your code }this property will return true, if page validation succeeded
Regards,
Jayesh
daveharney
Member
91 Points
43 Posts
Re: create user wizard email validation
Apr 05, 2012 08:33 AM|LINK
Thanks 2pac for the reply.
The problem is that I never see any of these events the first time the user clicks "create user" after he has fixed his email:
Protected Sub CreateUserWizard1_CreatingUser(sender As Object, e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles CreateUserWizard1.CreatingUser
MsgBox("creating user")
End Sub
Protected Sub CreateUserWizard1_CreatedUser(sender As Object, e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
MsgBox("created user")
End Sub
Protected Sub CreateUserWizard1_CreateUserError(sender As Object, e As System.Web.UI.WebControls.CreateUserErrorEventArgs) Handles CreateUserWizard1.CreateUserError
MsgBox("creating user error")
End Sub
I don't see the first two messages until the user clicks the create user button the second time (if they actually do). And, I never see that third "createUserError" message.
So, how can I tell that the user clicked that "create user" button for any reason? How can I wire an event just to that button itself?
Thanks.
olivespike
Member
176 Points
63 Posts
Re: create user wizard email validation
Apr 06, 2012 12:48 AM|LINK
Perhaps you're missing FinishDestinationPageUrl; such as: