日期:2014-05-18  浏览次数:20402 次

对CreateUserWizard增加的控件中的数据进行验证
我在CreateUserWizard控件中加入了两个DropDownList,我想在用户添加前对是否选择了DropDownList中的正确数据进行验证,如果验证成功再注册为用户。
我在
Private   Sub   CreateUserWizard1_CreatingUser(ByVal   sender   As   Object,   ByVal   e   As   System.Web.UI.WebControls.LoginCancelEventArgs)   Handles   CreateUserWizard1.CreatingUser
                Dim   MyUserdzz   As   DropDownList
                Dim   MyUserdzb   As   DropDownList
                MyUserdzz   =   CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl( "DropDownList1 ")
                MyUserdzb   =   CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl( "DropDownList2 ")
                If   MyUserdzz.SelectedIndex   =   0   Or   MyUserdzb.SelectedIndex   =   0   Then
                        MsgBox( "请选择街道名称和企业名称 ")
                        Exit   Sub
                End   If
             
        End   Sub
现在的问题是:这段代码可以在用户没有选择项目时进行提示,但是提示完后,依然进行了注册,我如何才能在用户没有选择项目时进行提示并停止注册动作。
谢谢

------解决方案--------------------
在模板内放置验证控件就可以了。