如题,报错:不允许使用子控件主要代码如下:private RequiredFieldValidator fieldValiator;
/// <summary>
/// 创建子控件
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
validator = new RequiredFieldValidator();
validator.ID = this.ID + "_Val";
.....
Controls.Add(validator );
}
/// <summary>
/// 创建子控件
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
validator = new RequiredFieldValidator();
validator.ID = this.ID + "_Val";
.....
Controls.Add(validator );
}
{
return new ControlCollection(this); }=======================================================================
Quiet easy, huh!? If you have the same problem when inheriting from out-of-the-box control, this will be the fix.
Hope this helps.
Reference: http://www.codeproject.com/KB/aspnet/DoesNotAllowChildControls.aspx顺便说一句,遇到解决不了的问题,请参考Google,语言选择英文。
http://www.google.com.hk/search?hl=en&source=hp&q=Does+Not+Allow+Child+Controls&meta=&aq=f&aqi=g-m2&aql=&oq=&gs_rfai=