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

Validators at cross purposes?

I'm working on a timesheet project that involves creating textboxes and
validators dynamically, and setting them in a placeholder to build a table.
The Regular Expression validator works fine, ensuring there are either 1 or
2 numbers, and then optionally a period and 1 or 2 numbers.

However, the Range Validator acts funny; I'm trying to have it ensure values
are between 0.01 and 24, and it works fine for values 2 or under. But when I
put 3 - 9 in, the validator fires like there is a mistake. But, if I use 03
instead of 3, it validates fine. I'm using different messages, so I know
it's the Range Validator causing this.

I've included the code I'm using to create the validators, and would
appreciate advice/opinions. I'm using VS.NET 2003 with the latest framework.
Thanks.

plcRange(intDIM, intCount) = New RangeValidator
plcRange(intDIM, intCount).ID = "rngTime_" & Year(DateNow) &
Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).ControlToValidate = "txtTime_" &
Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcRange(intDIM, intCount).ErrorMessage = "++"
plcRange(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcRange(intDIM, intCount).MinimumValue = 0.01
plcRange(intDIM, intCount).MaximumValue = 24.0
plcTable.Controls.Add(plcRange(intDIM, intCount))

plcValid(intDIM, intCount) = New RegularExpressionValidator
plcValid(intDIM, intCount).ID = "regTime_" & Year(DateNow) &
Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).ControlToValidate = "txtTime_" &
Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcValid(intDIM, intCount).ErrorMessage = "**"
plcValid(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcValid(intDIM, intCount).ValidationExpression =
"\d{1,2}([.]\d{1,2})?"
plcTable.Controls.Add(plcValid(intDIM, intCount))
--
Kenneth S. McAndrew
Software Developer, Information Concepts
km*******@infoconcepts.com
Nov 18 '05 #1
2 1171
Hi Ken:

Set the validator's Type property to ValidationDataType.Double. The
default type is String, so the range validator must be doing a string
comparisons on the control values, and thus the strange results.

Hope this helps,

--
Scott
http://www.OdeToCode.com

On Mon, 5 Jan 2004 14:48:41 -0500, "Ken McAndrew"
<km*******@infoconcepts.com> wrote:
I'm working on a timesheet project that involves creating textboxes and
validators dynamically, and setting them in a placeholder to build a table.
The Regular Expression validator works fine, ensuring there are either 1 or
2 numbers, and then optionally a period and 1 or 2 numbers.

However, the Range Validator acts funny; I'm trying to have it ensure values
are between 0.01 and 24, and it works fine for values 2 or under. But when I
put 3 - 9 in, the validator fires like there is a mistake. But, if I use 03
instead of 3, it validates fine. I'm using different messages, so I know
it's the Range Validator causing this.

I've included the code I'm using to create the validators, and would
appreciate advice/opinions. I'm using VS.NET 2003 with the latest framework.
Thanks.

plcRange(intDIM, intCount) = New RangeValidator
plcRange(intDIM, intCount).ID = "rngTime_" & Year(DateNow) &
Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).ControlToValidate = "txtTime_" &
Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcRange(intDIM, intCount).ErrorMessage = "++"
plcRange(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcRange(intDIM, intCount).MinimumValue = 0.01
plcRange(intDIM, intCount).MaximumValue = 24.0
plcTable.Controls.Add(plcRange(intDIM, intCount))

plcValid(intDIM, intCount) = New RegularExpressionValidator
plcValid(intDIM, intCount).ID = "regTime_" & Year(DateNow) &
Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).ControlToValidate = "txtTime_" &
Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcValid(intDIM, intCount).ErrorMessage = "**"
plcValid(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcValid(intDIM, intCount).ValidationExpression =
"\d{1,2}([.]\d{1,2})?"
plcTable.Controls.Add(plcValid(intDIM, intCount))


Nov 18 '05 #2
That did the trick. Thanks for the help.

--
Kenneth S. McAndrew
Software Developer, Information Concepts
km*******@infoconcepts.com
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:lu********************************@4ax.com...
Hi Ken:

Set the validator's Type property to ValidationDataType.Double. The
default type is String, so the range validator must be doing a string
comparisons on the control values, and thus the strange results.

Hope this helps,

--
Scott
http://www.OdeToCode.com

On Mon, 5 Jan 2004 14:48:41 -0500, "Ken McAndrew"
<km*******@infoconcepts.com> wrote:
I'm working on a timesheet project that involves creating textboxes and
validators dynamically, and setting them in a placeholder to build a table.The Regular Expression validator works fine, ensuring there are either 1 or2 numbers, and then optionally a period and 1 or 2 numbers.

However, the Range Validator acts funny; I'm trying to have it ensure valuesare between 0.01 and 24, and it works fine for values 2 or under. But when Iput 3 - 9 in, the validator fires like there is a mistake. But, if I use 03instead of 3, it validates fine. I'm using different messages, so I know
it's the Range Validator causing this.

I've included the code I'm using to create the validators, and would
appreciate advice/opinions. I'm using VS.NET 2003 with the latest framework.Thanks.

plcRange(intDIM, intCount) = New RangeValidator
plcRange(intDIM, intCount).ID = "rngTime_" & Year(DateNow) &Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).ControlToValidate = "txtTime_" &Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcRange(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcRange(intDIM, intCount).ErrorMessage = "++"
plcRange(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcRange(intDIM, intCount).MinimumValue = 0.01
plcRange(intDIM, intCount).MaximumValue = 24.0
plcTable.Controls.Add(plcRange(intDIM, intCount))

plcValid(intDIM, intCount) = New RegularExpressionValidator plcValid(intDIM, intCount).ID = "regTime_" & Year(DateNow) &Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).ControlToValidate = "txtTime_" &Year(DateNow) & Month(DateNow) & intDIM & "_" & intCount
plcValid(intDIM, intCount).Display =
ValidatorDisplay.Dynamic
plcValid(intDIM, intCount).ErrorMessage = "**"
plcValid(intDIM, intCount).ForeColor = lblWidth.ForeColor
plcValid(intDIM, intCount).ValidationExpression =
"\d{1,2}([.]\d{1,2})?"
plcTable.Controls.Add(plcValid(intDIM, intCount))

Nov 18 '05 #3

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

Similar topics

8
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
1
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
6
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators...
1
by: Fabio Gouw | last post by:
Hello, I have an web application that has a page with one dropdownlist (AutoPostBack property is True), and some textboxes associated with regular expression validators that avoid html tags. My...
3
by: John Blair | last post by:
Hi, I have validators outside of a datagrid (for adding a new grid row) - however when i click "edit" column and then the "update" column of a grid row that has been edited - my other...
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...
2
by: VK | last post by:
Cross-Domain Interactor (CDI) StarGates 0.9 is released I believe that the post "JSON - Cross domain request"...
2
by: Jordan S. | last post by:
I'm experimenting with dynamically inserting custom composite Web server controls onto a page. For testing purposes I have two custom composite Web server controls that each have a couple of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.