L
Lloyd Dupont
I have a composite control rougly like that::
====
class BlogComments : Control, INamingContainer, IPostBackEventHandler
{
Panel pAddComment;
TextBox tTitle;
protected override void CreateChildControls()
{
pAddComment = new Panel();
Controls.Add(pAddComment);
pAddComment.Controls.Add(tTitle = new TextBox());
tTitle.ID = "tTitle";
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ErrorMessage = strings.Required;
rfv.ControlToValidate = "tTitle";
pAddComment.Controls.Add(rfv);
}
}
====
Now when I try to display a page (.aspx) where there is a BlogComment I get the following error:
===
[HttpException (0x80004005): Unable to find control id 'tTitle' referenced by the 'ControlToValidate' property of ''.]
System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +221
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +178
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid() +36
System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +46
===
Any tips?
====
class BlogComments : Control, INamingContainer, IPostBackEventHandler
{
Panel pAddComment;
TextBox tTitle;
protected override void CreateChildControls()
{
pAddComment = new Panel();
Controls.Add(pAddComment);
pAddComment.Controls.Add(tTitle = new TextBox());
tTitle.ID = "tTitle";
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ErrorMessage = strings.Required;
rfv.ControlToValidate = "tTitle";
pAddComment.Controls.Add(rfv);
}
}
====
Now when I try to display a page (.aspx) where there is a BlogComment I get the following error:
===
[HttpException (0x80004005): Unable to find control id 'tTitle' referenced by the 'ControlToValidate' property of ''.]
System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +221
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +178
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid() +36
System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +46
===
Any tips?