473,411 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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 3090
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ad | last post by:
I want to combine a TextBox and a RequiredFieldValidator into to a web custom control (name RequireTextBox ), But when I use RequireTextBox in web form, the RequiredFieldValidator has no action....
2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
3
by: me | last post by:
Is there any particular reason why a requiredfieldvalidator cant validate a listbox? I have bound the two together but the validator always returns false on isvalid and so does the Page, no matter...
0
by: Code Rodent | last post by:
Hi there, Please please could someone shed some like on a problem that I'm having using a combination of Wizards, ValidationGroups and ValidationSummary controls. What I want to do is to have a...
0
by: André Nobre | last post by:
Hi all, I´m having a little trouble with a requiredfieldvalitor in a custom control. I put a validator in runtime, as this code: protected override void OnInit(EventArgs e) { if...
1
by: Jeff | last post by:
hey asp.net 2.0 I'm trying to create a web page where users can register to my web portal. But I've run into a layout problem when using the data validator classes. The problem is that the...
0
by: shapper | last post by:
Hello, I am creating a custom control which uses TextBoxes and Required field validator. I am using INamingContainer in my custom control. When I use the control in a page I get an error: ...
4
by: =?Utf-8?B?Y3VyaW91cw==?= | last post by:
I am using a RegularExpressionValidator to validate a TextBox. I use "^?+(\.*)?$" to check for a real number. The control works fine as long as the user enters something in the TextBox; it does not...
0
by: suganya | last post by:
Hi I have written the code for Atlas ModalPopup Control . The code is as follows <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.