470,636 Members | 1,563 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

Problem with RequiredFieldValidator in custom (C#) control

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.CheckContr olValidationProperty(String name, String propertyName) +221
System.Web.UI.WebControls.BaseValidator.ControlPro pertiesValid() +178
System.Web.UI.WebControls.BaseValidator.get_Proper tiesValid() +36
System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +46
===
Any tips?

--
I have taken a vow of poverty. If you want to really piss me off, send me money.

Jan 13 '06 #1
1 2999
forget it, bug in my code, I change the ID of tTitle agin one line below...

"Lloyd Dupont" <net.galador@ld> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
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.CheckContr olValidationProperty(String name, String propertyName) +221
System.Web.UI.WebControls.BaseValidator.ControlPro pertiesValid() +178
System.Web.UI.WebControls.BaseValidator.get_Proper tiesValid() +36
System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +46
===
Any tips?

--
I have taken a vow of poverty. If you want to really piss me off, send me money.

Jan 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bill yeager | last post: by
reply views Thread by Andrť Nobre | last post: by
1 post views Thread by Jeff | last post: by
reply views Thread by shapper | last post: by
4 posts views Thread by =?Utf-8?B?Y3VyaW91cw==?= | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.