By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 802 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

How do I extend the RangeValidator control to handle custom dates?

P: n/a
jk
Looking through WebUIValidation.js, I discovered that the standard validators
don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would
like to do

To keep code to a minimum, I would like to extend the existing validator to
handle other common date formats and still be able to do both client and/or
server side validation as normal. Unfortunately, I am unable to get the
extended code to ever be called

I implemented the EvaluateIsValid method and registering a client script
within OnPreRender but this code never seems to run at all. I also tried
temporarily hacking ever instance of the WebUIValidation.js code on my
computer for my current version of ASP.NET without any change either

Ideas on debugging, extension or deployment in this scenario appreciated

Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
to fire the EvaluateIsValid method, call Page.IsValid property.

-- bruce (sqlwork.com)

"jk" <ju******@spamfactory.com> wrote in message
news:86**********************************@microsof t.com...
| Looking through WebUIValidation.js, I discovered that the standard
validators
| don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would
| like to do
|
| To keep code to a minimum, I would like to extend the existing validator
to
| handle other common date formats and still be able to do both client
and/or
| server side validation as normal. Unfortunately, I am unable to get the
| extended code to ever be called
|
| I implemented the EvaluateIsValid method and registering a client script
| within OnPreRender but this code never seems to run at all. I also tried
| temporarily hacking ever instance of the WebUIValidation.js code on my
| computer for my current version of ASP.NET without any change either
|
| Ideas on debugging, extension or deployment in this scenario appreciated
|
Nov 19 '05 #2

P: n/a
jk
Thanks

I can try that. Why do I need to do an explicit Page.IsValid when using the
extended control whereas the standard validation fires automatically without
me having to do anything like that?

"bruce barker" wrote:
to fire the EvaluateIsValid method, call Page.IsValid property.

-- bruce (sqlwork.com)

"jk" <ju******@spamfactory.com> wrote in message
news:86**********************************@microsof t.com...
| Looking through WebUIValidation.js, I discovered that the standard
validators
| don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would
| like to do
|
| To keep code to a minimum, I would like to extend the existing validator
to
| handle other common date formats and still be able to do both client
and/or
| server side validation as normal. Unfortunately, I am unable to get the
| extended code to ever be called
|
| I implemented the EvaluateIsValid method and registering a client script
| within OnPreRender but this code never seems to run at all. I also tried
| temporarily hacking ever instance of the WebUIValidation.js code on my
| computer for my current version of ASP.NET without any change either
|
| Ideas on debugging, extension or deployment in this scenario appreciated
|

Nov 19 '05 #3

P: n/a
Simply put, the Microsoft CompareValidator is limited to short date pattern.
No month names, just digits. Don't bother modifying their client-side code.
The ramifications are big. For example, validators also validate on the
server side. So you have to enhance the server side validator too.

Here are two solutions:
1. Use a CustomValidator where you write both the client and server side
evaluation functions.
2. Use Peter's Date Package
(http://www.peterblum.com/datecontrols/home.aspx). It provides a DateTextBox
with popup calendar. You have the option of using abbreviated date entry:
MMM. It includes a number of validators which support the abbreviated date
entry. The validators include full client-side support.
When you install the free trial version, add a DateTextBox to the page. Then
set the AllowMonthNames property to "Show"; this will give you abbreviated
month entry.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:54**********************************@microsof t.com...
Thanks

I can try that. Why do I need to do an explicit Page.IsValid when using
the
extended control whereas the standard validation fires automatically
without
me having to do anything like that?

"bruce barker" wrote:
to fire the EvaluateIsValid method, call Page.IsValid property.

-- bruce (sqlwork.com)

"jk" <ju******@spamfactory.com> wrote in message
news:86**********************************@microsof t.com...
| Looking through WebUIValidation.js, I discovered that the standard
validators
| don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I
would
| like to do
|
| To keep code to a minimum, I would like to extend the existing
validator
to
| handle other common date formats and still be able to do both client
and/or
| server side validation as normal. Unfortunately, I am unable to get
the
| extended code to ever be called
|
| I implemented the EvaluateIsValid method and registering a client
script
| within OnPreRender but this code never seems to run at all. I also
tried
| temporarily hacking ever instance of the WebUIValidation.js code on my
| computer for my current version of ASP.NET without any change either
|
| Ideas on debugging, extension or deployment in this scenario
appreciated
|

Nov 19 '05 #4

P: n/a
jk
Thanks

It is because the standard validators work both client and server side that
I thought the most elegant solution is to extend the existing functionality
and reduce the need for custom code

I am aware there are alternatives to the approach I would like to take, but
I am interested in why extending the standard validators is not viable and
why to date I am having difficulty making this approach work

"Peter Blum" wrote:
Simply put, the Microsoft CompareValidator is limited to short date pattern.
No month names, just digits. Don't bother modifying their client-side code.
The ramifications are big. For example, validators also validate on the
server side. So you have to enhance the server side validator too.

Here are two solutions:
1. Use a CustomValidator where you write both the client and server side
evaluation functions.
2. Use Peter's Date Package
(http://www.peterblum.com/datecontrols/home.aspx). It provides a DateTextBox
with popup calendar. You have the option of using abbreviated date entry:
MMM. It includes a number of validators which support the abbreviated date
entry. The validators include full client-side support.
When you install the free trial version, add a DateTextBox to the page. Then
set the AllowMonthNames property to "Show"; this will give you abbreviated
month entry.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:54**********************************@microsof t.com...
Thanks

I can try that. Why do I need to do an explicit Page.IsValid when using
the
extended control whereas the standard validation fires automatically
without
me having to do anything like that?

"bruce barker" wrote:
to fire the EvaluateIsValid method, call Page.IsValid property.

-- bruce (sqlwork.com)

"jk" <ju******@spamfactory.com> wrote in message
news:86**********************************@microsof t.com...
| Looking through WebUIValidation.js, I discovered that the standard
validators
| don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I
would
| like to do
|
| To keep code to a minimum, I would like to extend the existing
validator
to
| handle other common date formats and still be able to do both client
and/or
| server side validation as normal. Unfortunately, I am unable to get
the
| extended code to ever be called
|
| I implemented the EvaluateIsValid method and registering a client
script
| within OnPreRender but this code never seems to run at all. I also
tried
| temporarily hacking ever instance of the WebUIValidation.js code on my
| computer for my current version of ASP.NET without any change either
|
| Ideas on debugging, extension or deployment in this scenario
appreciated
|


Nov 19 '05 #5

P: n/a
Hi JK,

Perhaps you didn't know, but I am the author of the leading replacement to
the Microsoft validators (Professional Validation And More).
I had written a number of Microsoft style validators (including those I
mentioned in Peter's Date Package) and kept coming up against its
limitations. Many are due to their design, which is really pretty poor at
extendability. You can find a detailed analysis of these limitations at
http://www.peterblum.com/vam/valmain.aspx.

In this case, the Type property is connected to several internal systems on
the server side. The property itself is an enumerated type, so its not
extendable. You cannot create a new "Date with abbrev month" type in the
property. Both the RangeValidator and CompareValidator use the Type property
to run code that converts strings and compares them. So they are subclassed
from System.Web.UI.WebControls.BaseCompareValidator. BaseCompareValidator
offers two methods to handle the Type property values. Unfortunately, they
are static/shared, not overrideable. So you cannot expand this system.

In Professional Validation And More, I defined data types as unique objects.
The Type property is expandable. The user can create new data types,
following documentation I provide in a free Developer's Kit.

Just to avoid confusion, Peter's Date Package offers validators for its
DateTextBox. Professional Validation And More also offers DataType=Date on
its validators, but its own format is limited to the shortDatePattern. Users
who have both products will see that Peter's Date Package extends the list
of data types offered on all validators so they can have the extended date
format that includes the abbreviated months. For this particular issue,
Peter's Date Package will solve the problem.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:21**********************************@microsof t.com...
Thanks

It is because the standard validators work both client and server side
that
I thought the most elegant solution is to extend the existing
functionality
and reduce the need for custom code

I am aware there are alternatives to the approach I would like to take,
but
I am interested in why extending the standard validators is not viable and
why to date I am having difficulty making this approach work

"Peter Blum" wrote:
Simply put, the Microsoft CompareValidator is limited to short date
pattern.
No month names, just digits. Don't bother modifying their client-side
code.
The ramifications are big. For example, validators also validate on the
server side. So you have to enhance the server side validator too.

Here are two solutions:
1. Use a CustomValidator where you write both the client and server side
evaluation functions.
2. Use Peter's Date Package
(http://www.peterblum.com/datecontrols/home.aspx). It provides a
DateTextBox
with popup calendar. You have the option of using abbreviated date entry:
MMM. It includes a number of validators which support the abbreviated
date
entry. The validators include full client-side support.
When you install the free trial version, add a DateTextBox to the page.
Then
set the AllowMonthNames property to "Show"; this will give you
abbreviated
month entry.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:54**********************************@microsof t.com...
> Thanks
>
> I can try that. Why do I need to do an explicit Page.IsValid when
> using
> the
> extended control whereas the standard validation fires automatically
> without
> me having to do anything like that?
>
> "bruce barker" wrote:
>
>> to fire the EvaluateIsValid method, call Page.IsValid property.
>>
>> -- bruce (sqlwork.com)
>>
>> "jk" <ju******@spamfactory.com> wrote in message
>> news:86**********************************@microsof t.com...
>> | Looking through WebUIValidation.js, I discovered that the standard
>> validators
>> | don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I
>> would
>> | like to do
>> |
>> | To keep code to a minimum, I would like to extend the existing
>> validator
>> to
>> | handle other common date formats and still be able to do both client
>> and/or
>> | server side validation as normal. Unfortunately, I am unable to get
>> the
>> | extended code to ever be called
>> |
>> | I implemented the EvaluateIsValid method and registering a client
>> script
>> | within OnPreRender but this code never seems to run at all. I also
>> tried
>> | temporarily hacking ever instance of the WebUIValidation.js code on
>> my
>> | computer for my current version of ASP.NET without any change either
>> |
>> | Ideas on debugging, extension or deployment in this scenario
>> appreciated
>> |
>>
>>
>>


Nov 19 '05 #6

P: n/a
jk
Thanks

FYI: we are already pursuing options to purchase both packages

I do not wish to change the data type, just the behaviour of the
client/server validation routines. This looks like a dead end unless someone
has successfully subclassed the rangevalidator or comparevalidator and can
show me where I'm going wrong

"Peter Blum" wrote:
Hi JK,

Perhaps you didn't know, but I am the author of the leading replacement to
the Microsoft validators (Professional Validation And More).
I had written a number of Microsoft style validators (including those I
mentioned in Peter's Date Package) and kept coming up against its
limitations. Many are due to their design, which is really pretty poor at
extendability. You can find a detailed analysis of these limitations at
http://www.peterblum.com/vam/valmain.aspx.

In this case, the Type property is connected to several internal systems on
the server side. The property itself is an enumerated type, so its not
extendable. You cannot create a new "Date with abbrev month" type in the
property. Both the RangeValidator and CompareValidator use the Type property
to run code that converts strings and compares them. So they are subclassed
from System.Web.UI.WebControls.BaseCompareValidator. BaseCompareValidator
offers two methods to handle the Type property values. Unfortunately, they
are static/shared, not overrideable. So you cannot expand this system.

In Professional Validation And More, I defined data types as unique objects.
The Type property is expandable. The user can create new data types,
following documentation I provide in a free Developer's Kit.

Just to avoid confusion, Peter's Date Package offers validators for its
DateTextBox. Professional Validation And More also offers DataType=Date on
its validators, but its own format is limited to the shortDatePattern. Users
who have both products will see that Peter's Date Package extends the list
of data types offered on all validators so they can have the extended date
format that includes the abbreviated months. For this particular issue,
Peter's Date Package will solve the problem.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:21**********************************@microsof t.com...
Thanks

It is because the standard validators work both client and server side
that
I thought the most elegant solution is to extend the existing
functionality
and reduce the need for custom code

I am aware there are alternatives to the approach I would like to take,
but
I am interested in why extending the standard validators is not viable and
why to date I am having difficulty making this approach work

"Peter Blum" wrote:
Simply put, the Microsoft CompareValidator is limited to short date
pattern.
No month names, just digits. Don't bother modifying their client-side
code.
The ramifications are big. For example, validators also validate on the
server side. So you have to enhance the server side validator too.

Here are two solutions:
1. Use a CustomValidator where you write both the client and server side
evaluation functions.
2. Use Peter's Date Package
(http://www.peterblum.com/datecontrols/home.aspx). It provides a
DateTextBox
with popup calendar. You have the option of using abbreviated date entry:
MMM. It includes a number of validators which support the abbreviated
date
entry. The validators include full client-side support.
When you install the free trial version, add a DateTextBox to the page.
Then
set the AllowMonthNames property to "Show"; this will give you
abbreviated
month entry.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"jk" <ju******@spamfactory.com> wrote in message
news:54**********************************@microsof t.com...
> Thanks
>
> I can try that. Why do I need to do an explicit Page.IsValid when
> using
> the
> extended control whereas the standard validation fires automatically
> without
> me having to do anything like that?
>
> "bruce barker" wrote:
>
>> to fire the EvaluateIsValid method, call Page.IsValid property.
>>
>> -- bruce (sqlwork.com)
>>
>> "jk" <ju******@spamfactory.com> wrote in message
>> news:86**********************************@microsof t.com...
>> | Looking through WebUIValidation.js, I discovered that the standard
>> validators
>> | don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I
>> would
>> | like to do
>> |
>> | To keep code to a minimum, I would like to extend the existing
>> validator
>> to
>> | handle other common date formats and still be able to do both client
>> and/or
>> | server side validation as normal. Unfortunately, I am unable to get
>> the
>> | extended code to ever be called
>> |
>> | I implemented the EvaluateIsValid method and registering a client
>> script
>> | within OnPreRender but this code never seems to run at all. I also
>> tried
>> | temporarily hacking ever instance of the WebUIValidation.js code on
>> my
>> | computer for my current version of ASP.NET without any change either
>> |
>> | Ideas on debugging, extension or deployment in this scenario
>> appreciated
>> |
>>
>>
>>


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.