473,324 Members | 2,581 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,324 software developers and data experts.

Adding validators to CompositeControl

Hi all

I finally got around to creating some WebControl classes, however I want to
add some validation to my custom control, it's a descendant of
CompositeControl.

I get the exception: Unable to find control id 'txtForename' referenced by
the 'ControlToValidate' property of 'valType'

Here is how I'm creating the validtor(s):

protected override void CreateChildControls()

{

// Create the custom validator

CustomValidator customVal = new CustomValidator();

customVal.ID = ID_CUSTOMVAL;

customVal.ServerValidate += new
ServerValidateEventHandler(validator_ServerValidat e);

customVal.Text = TEXT_VALIDATOR;

Controls.Add(customVal);

// Create the compare validator

CompareValidator typeVal = new CompareValidator();

typeVal.ID = ID_TYPEVAL;

typeVal.Operator = ValidationCompareOperator.DataTypeCheck;

typeVal.Text = TEXT_VALIDATOR;

typeVal.ControlToValidate = ID;

Controls.Add(typeVal);

base.CreateChildControls();

}
Any ideas?

Thanks
Kev
Jun 15 '06 #1
1 2459
Oh, hang on, I think I see the problem.

Kev

"Mantorok" <ma******@mantorok.com> wrote in message
news:e6**********@newsfeed.th.ifl.net...
Hi all

I finally got around to creating some WebControl classes, however I want
to add some validation to my custom control, it's a descendant of
CompositeControl.

I get the exception: Unable to find control id 'txtForename' referenced by
the 'ControlToValidate' property of 'valType'

Here is how I'm creating the validtor(s):

protected override void CreateChildControls()

{

// Create the custom validator

CustomValidator customVal = new CustomValidator();

customVal.ID = ID_CUSTOMVAL;

customVal.ServerValidate += new
ServerValidateEventHandler(validator_ServerValidat e);

customVal.Text = TEXT_VALIDATOR;

Controls.Add(customVal);

// Create the compare validator

CompareValidator typeVal = new CompareValidator();

typeVal.ID = ID_TYPEVAL;

typeVal.Operator = ValidationCompareOperator.DataTypeCheck;

typeVal.Text = TEXT_VALIDATOR;

typeVal.ControlToValidate = ID;

Controls.Add(typeVal);

base.CreateChildControls();

}
Any ideas?

Thanks
Kev

Jun 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D Sheldon | last post by:
I am creating a server control that adds web controls (i.e. textboxes, etc) to a form. I use HtmlTable to build the table and insert the controls. Now I want to add validators to the textbox. Here...
0
by: D Sheldon | last post by:
Can anyone show me how to add validators (programatically) at the PreRender stage in C# I built a server control that builds a table with input boxes. The input boxes are added programmatically...
0
by: D Sheldon | last post by:
Can anyone show me how to add validators (programatically) at the PreRender stage in C# I built a server control that builds a table with WebControls. The WebControls are added programmatically...
1
by: Jack | last post by:
Hi, I have a page with a repeater control that contains textboxes. I'm trying to create a validation class that is called by my page. A method in this class iterates through all the controls...
2
by: Electric Co. | last post by:
Hello, I have two questions: 1.) How successfully does ASP.NET 2005 handle custom composite controls nested inside of custom composite controls? For example:
1
by: Griff | last post by:
Hi I want to create an n-tier custom server control. The idea is that the control will determine which "view" will be used. By this I mean User A may want the data displayed as a tree-view,...
0
by: Steve Richter | last post by:
my composite control does not render correctly the 2nd time it is made visible. When I change the base class from CompositeControl to WebControl, the control works as it should. public class...
2
by: Nathan Sokalski | last post by:
I am write a CompositeControl, and one of the controls being included is a Repeater. This is my first time including a templated control in a control other than a UserControl. I am not sure how to...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Tried posting this on Build Controls but then saw that's a pretty slow group... Kind of a typical request from product management - they want to be able to swap in different 3rd party...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.