Validating Dates In GridView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Just Me

    #1

    Validating Dates In GridView

    Hi people.

    I am attempting to determine how best to prevent a users date entry in an
    update action from causing a format exception. The dates are UK, but the
    user may try to put in a 'US' format.

    I have a datasource which is wired to my DAL/update function.

    1.) On the server side.

    Where do I need to check this ?

    2.) On the client side.

    If I wanted to set up JSCRIPT validation, whats the best way to acheive this
    ?


    I dont neccesarilly need fine detail, but a broad brush roadmap of what to
    do and Ill work it out from there.

    Thanks. !



  • Just Me

    #2
    Re: Validating Dates In GridView

    Ahh, dont worry. Ive found a way.

    Basic Steps to enable this of client side ( Per Text Input ) is this.

    1.) Handle GridView1_RowDa taBound

    2.) Find and cast the required textbox to a textbox.

    3.) Add an attribute("onke ypress","yourDa teFormatValidat ionFunction");

    I still need to validate on the server that the actual date exists, but
    thats not going to be too troublesome.

    Cheers


    "Just Me" <news.microsoft .comwrote in message
    news:OXgoco4iIH A.1168@TK2MSFTN GP02.phx.gbl...
    Hi people.
    >
    I am attempting to determine how best to prevent a users date entry in an
    update action from causing a format exception. The dates are UK, but the
    user may try to put in a 'US' format.
    >
    I have a datasource which is wired to my DAL/update function.
    >
    1.) On the server side.
    >
    Where do I need to check this ?
    >
    2.) On the client side.
    >
    If I wanted to set up JSCRIPT validation, whats the best way to acheive
    this ?
    >
    >
    I dont neccesarilly need fine detail, but a broad brush roadmap of what to
    do and Ill work it out from there.
    >
    Thanks. !
    >
    >
    >

    Comment

    • Stan

      #3
      Re: Validating Dates In GridView

      On 21 Mar, 19:28, "Just Me" <news.microsoft .comwrote:
      Hi people.
      >
      I am attempting to determine how best to prevent a users date entry in an
      update action from causing a format exception. The dates are UK, but the
      user may try to put in a 'US' format.
      >
      I have a datasource which is wired to my DAL/update function.
      >
      1.) On the server side.
      >
      Where do I need to check this ?
      >
      2.) On the client side.
      >
      If I wanted to set up JSCRIPT validation, whats the best way to acheive this
      ?
      >
      I dont neccesarilly need fine detail, but a broad brush roadmap of what to
      do and Ill work it out from there.
      >
      Thanks. !
      Hi

      Use a CompareValidato r control for a client-side check prior to
      postback. Set the 'operator' (properties window) property to
      DataTypeCheck. You can use this in conjunction with a RangeValidator
      to filter on the required period if applicable.

      Unfortunately there is no way to guarantee day/month v month/day
      ambiguity for text input. Most web sites that require date input use
      drop-down lists for day and month instead.

      Alternatively use the ASP.NET calendar control. They require more
      space on the page and can generate a lot of round trips during the
      selection process but are user friendly and easy to work with on the
      development side.

      HTH

      Comment

      Working...