473,413 Members | 1,807 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,413 software developers and data experts.

Dynamic Validator Help Please

I have a form where I create dynamic controls at runtime. With this, I am
adding a dynamic required field validator to each control as needed, but the
validators are not firing when I click submit. The submit button was placed
at design time and its causesvalidation property is set to true. Can someone
tell me if something is missing from my code? Thank you.

1. Code to add dynamic control works fine and I get the Id of the textbox
control
2. Then I see if a validator is required and add it...code below for that.
3. I have the validator display set to none because I have a validation
summary control, placed at design time, that I want to display. Is there
something I need to do to make the validation summary know the required field
validator is there, or something else I'm not thinking of? Thank you.

if (required)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ID = "validator" + controlCount.ToString();
validator.ControlToValidate = textBox.ID;
validator.ErrorMessage = "Please fill out the textbox ";
validator.Display = ValidatorDisplay.None;
phContainer.Controls.Add(validator);
}
Nov 15 '06 #1
2 4515
try adding:

validator.Enabled =true;
validator.EnableClientScript =true;
validator.Visible =true;

-- bruce (sqlwork.com)

"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:49**********************************@microsof t.com...
>I have a form where I create dynamic controls at runtime. With this, I am
adding a dynamic required field validator to each control as needed, but
the
validators are not firing when I click submit. The submit button was
placed
at design time and its causesvalidation property is set to true. Can
someone
tell me if something is missing from my code? Thank you.

1. Code to add dynamic control works fine and I get the Id of the textbox
control
2. Then I see if a validator is required and add it...code below for that.
3. I have the validator display set to none because I have a validation
summary control, placed at design time, that I want to display. Is there
something I need to do to make the validation summary know the required
field
validator is there, or something else I'm not thinking of? Thank you.

if (required)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ID = "validator" + controlCount.ToString();
validator.ControlToValidate = textBox.ID;
validator.ErrorMessage = "Please fill out the textbox ";
validator.Display = ValidatorDisplay.None;
phContainer.Controls.Add(validator);
}

Nov 15 '06 #2
Thanks for the reply, but still the validators do not seem to fire and the
page is submitted. The validators are added the same time as the other
controls, in the OnInit event. Maybe...can you not use validators added in
the OnInit event?

"bruce barker (sqlwork.com)" wrote:
try adding:

validator.Enabled =true;
validator.EnableClientScript =true;
validator.Visible =true;

-- bruce (sqlwork.com)

"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:49**********************************@microsof t.com...
I have a form where I create dynamic controls at runtime. With this, I am
adding a dynamic required field validator to each control as needed, but
the
validators are not firing when I click submit. The submit button was
placed
at design time and its causesvalidation property is set to true. Can
someone
tell me if something is missing from my code? Thank you.

1. Code to add dynamic control works fine and I get the Id of the textbox
control
2. Then I see if a validator is required and add it...code below for that.
3. I have the validator display set to none because I have a validation
summary control, placed at design time, that I want to display. Is there
something I need to do to make the validation summary know the required
field
validator is there, or something else I'm not thinking of? Thank you.

if (required)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ID = "validator" + controlCount.ToString();
validator.ControlToValidate = textBox.ID;
validator.ErrorMessage = "Please fill out the textbox ";
validator.Display = ValidatorDisplay.None;
phContainer.Controls.Add(validator);
}


Nov 15 '06 #3

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

Similar topics

1
by: coollzh | last post by:
i have a asp.net Form with serval input textbox and serval validators to validate the user input dynamic when user input wrongly in the textbox, the validator will worn the user for wrong inputing...
1
by: Luis Ferrao | last post by:
Hi, To understand the problem, a small description of the situation should be provided: I have a Field Control that is made of a one row table with three columns. The table width is 100%, the...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
2
by: Tumurbaatar S. | last post by:
I dynamically add columns to DataGrid as described in MSDN articles "Top Questions about the DataGrid Web Server Control" and "Creating Web Server Control Templates Programmatically". The columns...
3
by: rgparkins | last post by:
Hi I am currently having problems with Validators in a user control. I am creating a wizard sign-up process which have the allocated step (hyperlinks" at the top of the page. A user can also...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
0
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validators to each control as needed, but the validators are not firing when I click...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.