468,727 Members | 1,467 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,727 developers. It's quick & easy.

looking for a Date Time Control..

RSB
Hi Every one ,
IS there any Date Time Control with .Net. All i want to read is the Date and
Time in a Single Field like 12/31/2004 09:23:23AM.
if there is any then any examples for it. and if not then how to Validate
the Text field for above.

thanks
RSB
Nov 18 '05 #1
3 3477
You can use CompareValidator by setting
Operator property to DataTypeCheck and Type property to DateTime, then for
the control set in the ControlToValidate the CompareValidator will get the
entered data and will try to convert it to the given type. if the data is
incorrect the CompareValidator will rise an error messsage.

When you use Operator=DataTypeCheck then the ControlToCompare is ignored

Regards
Martin

"RSB" <rs*****@hotmail.com> wrote in message
news:#H**************@TK2MSFTNGP09.phx.gbl...
Hi Every one ,
IS there any Date Time Control with .Net. All i want to read is the Date and Time in a Single Field like 12/31/2004 09:23:23AM.
if there is any then any examples for it. and if not then how to Validate
the Text field for above.

thanks
RSB

Nov 18 '05 #2
RSB
Hi Martin,
Thanks for he reply..
Now i was checking the CompareValidator and for "TYPE" property it does not
support DateTime.. it only supports Date..
Please advice.
is there any Control as such which provides me the both..

thanks

RSB

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:ed*************@TK2MSFTNGP12.phx.gbl...
You can use CompareValidator by setting
Operator property to DataTypeCheck and Type property to DateTime, then for
the control set in the ControlToValidate the CompareValidator will get the
entered data and will try to convert it to the given type. if the data is
incorrect the CompareValidator will rise an error messsage.

When you use Operator=DataTypeCheck then the ControlToCompare is ignored

Regards
Martin

"RSB" <rs*****@hotmail.com> wrote in message
news:#H**************@TK2MSFTNGP09.phx.gbl...
Hi Every one ,
IS there any Date Time Control with .Net. All i want to read is the Date and Time in a Single Field like 12/31/2004 09:23:23AM.
if there is any then any examples for it. and if not then how to Validate
the Text field for above.

thanks
RSB


Nov 18 '05 #3
You are correct that the CompareValidator does not support Date + Time. You
will have to write a custom validator or consider an alternative design.
With a CustomValidator, on the server side you can use the DateTime
structure's ParseExact() method. If it throws an exception, it indicates a
bad entry.

May I suggest an alternative design? By combining both date and time into
one textbox, you are asking for the user to be very careful with formatting.
Users have to know both date and time patterns that you are expecting, plus
any separator rule. Often you assist users in entering dates with a popup
calendar. Time might have similar tools. If you allowed separate date and
time fields, you not only can add a popup calendar, but its also easier to
install client-side keystroke filtering to avoid illegal character entry.
Finally, these separate fields are easier to validate. You know that
CompareValidator can handle a date. You still would have to build a
validator for time.

My "Peter's Date Package" is a solution that includes datetextbox with popup
calendar, timeofdaytextbox, and validators for both. The two fields can
interact together. You can get and set one DateTime value and the software
interacts with both. http://www.peterblum.com/datecontrols/home.aspx.

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

"RSB" <rs*****@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP12.phx.gbl...
Hi Martin,
Thanks for he reply..
Now i was checking the CompareValidator and for "TYPE" property it does not support DateTime.. it only supports Date..
Please advice.
is there any Control as such which provides me the both..

thanks

RSB

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:ed*************@TK2MSFTNGP12.phx.gbl...
You can use CompareValidator by setting
Operator property to DataTypeCheck and Type property to DateTime, then for
the control set in the ControlToValidate the CompareValidator will get the
entered data and will try to convert it to the given type. if the data is
incorrect the CompareValidator will rise an error messsage.

When you use Operator=DataTypeCheck then the ControlToCompare is ignored

Regards
Martin

"RSB" <rs*****@hotmail.com> wrote in message
news:#H**************@TK2MSFTNGP09.phx.gbl...
Hi Every one ,
IS there any Date Time Control with .Net. All i want to read is the Date

and
Time in a Single Field like 12/31/2004 09:23:23AM.
if there is any then any examples for it. and if not then how to Validate the Text field for above.

thanks
RSB


Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Hussein Patwa | last post: by
3 posts views Thread by Marauderz | last post: by
8 posts views Thread by gumi | last post: by
4 posts views Thread by Michel Posseth [MCP] | last post: by
1 post views Thread by Susan Bricker | last post: by
2 posts views Thread by fniles | last post: by
1 post views Thread by CARIGAR | last post: by
9 posts views Thread by bryonone | last post: by
xarzu
1 post views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.