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

Discussion in 'ASP .Net' started by =?Utf-8?B?ams=?=, Dec 20, 2004.

  1. 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
     
    =?Utf-8?B?ams=?=, Dec 20, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?ams=?=

    bruce barker Guest

    to fire the EvaluateIsValid method, call Page.IsValid property.

    -- bruce (sqlwork.com)

    "jk" <> wrote in message
    news:...
    | 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
    |
     
    bruce barker, Dec 20, 2004
    #2
    1. Advertising

  3. Re: How do I extend the RangeValidator control to handle custom da

    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" <> wrote in message
    > news:...
    > | 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
    > |
    >
    >
    >
     
    =?Utf-8?B?ams=?=, Dec 22, 2004
    #3
  4. =?Utf-8?B?ams=?=

    Peter Blum Guest

    Re: How do I extend the RangeValidator control to handle custom da

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "jk" <> wrote in message
    news:...
    > 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" <> wrote in message
    >> news:...
    >> | 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
    >> |
    >>
    >>
    >>
     
    Peter Blum, Dec 22, 2004
    #4
  5. Re: How do I extend the RangeValidator control to handle custom da

    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:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "jk" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > >> news:...
    > >> | 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
    > >> |
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?ams=?=, Dec 23, 2004
    #5
  6. =?Utf-8?B?ams=?=

    Peter Blum Guest

    Re: How do I extend the RangeValidator control to handle custom da

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "jk" <> wrote in message
    news:...
    > 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:
    >> Creator of "Professional Validation And More" at
    >> http://www.peterblum.com/vam/home.aspx
    >>
    >> "jk" <> wrote in message
    >> news:...
    >> > 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" <> wrote in message
    >> >> news:...
    >> >> | 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
    >> >> |
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Peter Blum, Dec 23, 2004
    #6
  7. Re: How do I extend the RangeValidator control to handle custom da

    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:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "jk" <> wrote in message
    > news:...
    > > 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:
    > >> Creator of "Professional Validation And More" at
    > >> http://www.peterblum.com/vam/home.aspx
    > >>
    > >> "jk" <> wrote in message
    > >> news:...
    > >> > 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" <> wrote in message
    > >> >> news:...
    > >> >> | 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
    > >> >> |
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?ams=?=, Dec 24, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    911
    Rob Schieber
    Sep 30, 2005
  2. Replies:
    1
    Views:
    337
    Chineme Nnamdi
    May 9, 2006
  3. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    235
    Mark Schupp
    Aug 9, 2004
  4. Replies:
    1
    Views:
    240
    Jano Svitok
    Jul 17, 2007
  5. kellygreer1

    RFC-822 dates into Ruby dates

    kellygreer1, Jun 8, 2008, in forum: Ruby
    Replies:
    1
    Views:
    269
    Eric I.
    Jun 8, 2008
Loading...

Share This Page