首页 新闻 会员 周边 捐助

asp.net用户自定义控件添加验证控件为何不起作用

0
[已关闭问题]
<P>一个自定义控件类继承CompositeControl</P> <P>一个TextBox控件和</P> <P>一个RequiredFieldValidator控件</P> <P>但RequiredFieldValidator控件验证TextBox非空无效</P>
问题补充: using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using System.Web.UI; using System.Collections; namespace LianX { public class JavaScript : CompositeControl { private TextBox _textboxPwd;//密码 private TextBox _textboxName;//登录名 private TextBox _textboxpassword;//密码确认 private TextBox _textboxEmail;//邮箱 private DropDownList _ddlSecurity;//安全问题 private TextBox _textboxSolution;//问题答案 private Button _button;//提交 private RequiredFieldValidator _rfvName;//验证登录名是否为空 private RequiredFieldValidator _rfvPwd;//验证密码是否为空 private CompareValidator _cvPassword;//验证密码的一致 private RegularExpressionValidator _revEmail;//验证邮箱的正确 private RequiredFieldValidator _rfvEmail;//验证邮箱是否为空 private RequiredFieldValidator _rfvSolution;//问题答案验证 public DropDownList DdlSecurity { get { EnsureChildControls(); return _ddlSecurity; } set { EnsureChildControls(); _ddlSecurity.DataSource = value; } } public string txtname { get { EnsureChildControls(); return _textboxPwd.Text; } set { EnsureChildControls(); _textboxPwd.Text = value; } } protected override void CreateChildControls() { //登录名 _textboxName = new TextBox(); _textboxName.ID = "textName"; this.Controls.Add(_textboxName); //密码 _textboxPwd = new TextBox(); _textboxPwd.ID = "textPwd"; this.Controls.Add(_textboxPwd); //确认密码 _textboxpassword = new TextBox();
思惟的主页 思惟 | 初学一级 | 园豆:200
提问于:2008-07-05 17:45
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册