Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Validating Dates In GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Just Me - 21 Mar 2008 20:28 GMT
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 - 21 Mar 2008 21:23 GMT
Ahh, dont worry. Ive found a way.

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

1.) Handle GridView1_RowDataBound

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

3.) Add an attribute("onkeypress","yourDateFormatValidationFunction");

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

Cheers

> Hi people.
>
[quoted text clipped - 17 lines]
>
> Thanks. !
Stan - 21 Mar 2008 22:10 GMT
> Hi people.
>
[quoted text clipped - 17 lines]
>
> Thanks. !

Hi

Use a CompareValidator 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.