2014年7月13日 星期日

[RESOLVED] CreateUserWizard custom error message


Hi All,


I am using CreateUserWizard to setup a registration page for users. I don't want the registration to happen for certain email addresses so am using the code below and it works fine. How can I give a custom error message to the user when they use an "invalid"
email? Thanks for the help.



protected void ValidateEmail_CreatingUser(object sender, LoginCancelEventArgs e)
{
if (RegisterUser.Email == "some-email@company.com")
{
e.Cancel = true;
}

}





Any ideas, please?



hi  sam1980, 


Acording to your description ,you want to create CreateUserWizard custom error message.


You  can  try   using  custom templates and use RegularExpressionValidator
control. for example ,html  source code as below :


         


           


               


                     


                       


                            ……


                            


                               


                                


                           

                          


                            


                               


                           


                       


                                                       E-mail:


                                   


                                   

                                        ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*                           


                                   *@\w+([-.]\w+)*\.\w+([-.]\w+)*"


                                 ControlToValidate="Email"   runat="server"        ErrorMessage="E-mail format is error">


                               


                                   


                               

                       


                    


               


               


                      ……


               


             


          


          Or trigger control event to judge.


沒有留言:

張貼留言