473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to enter date in the text box?

Hi guys:

I am very new to C# and would really appreciate if someone please help.
This is my first project and I am learning c#.

I have to create a form where user enters start date and end date. I will
use text boxes for both dates.

How can I format so user does not have to enter slashes and it display in
date format? ie. 01/01/2007.

Thank you.
Aug 16 '07 #1
4 5076
Mehbs wrote:
Hi guys:

I am very new to C# and would really appreciate if someone please help.
This is my first project and I am learning c#.

I have to create a form where user enters start date and end date. I will
use text boxes for both dates.

How can I format so user does not have to enter slashes and it display in
date format? ie. 01/01/2007.
Why text boxes for the date? There are other controls that are designed
to specifically support this type of validated entry. I would suggest a
DateTimePicker with a custom format of MM/dd/yyyy. If the
DateTimePicker is too restricted then a MaskedTextBox with mask set to
00/00/0000 should also work.
--
Tom Porterfield
Aug 16 '07 #2
Hi,

You better use the DateTimePicked and/or maskedTextBox

"Mehbs" <ms*****@comcast.netwrote in message
news:uf**************@TK2MSFTNGP06.phx.gbl...
Hi guys:

I am very new to C# and would really appreciate if someone please help.
This is my first project and I am learning c#.

I have to create a form where user enters start date and end date. I will
use text boxes for both dates.

How can I format so user does not have to enter slashes and it display in
date format? ie. 01/01/2007.

Thank you.


Aug 16 '07 #3
Thanks guys.

Now how do I get rid of time. I just need the date.
For example my dateticket name is dtperiod. When I try to display dtperiod,
it displays date and time.

Thanks
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi,

You better use the DateTimePicked and/or maskedTextBox

"Mehbs" <ms*****@comcast.netwrote in message
news:uf**************@TK2MSFTNGP06.phx.gbl...
>Hi guys:

I am very new to C# and would really appreciate if someone please help.
This is my first project and I am learning c#.

I have to create a form where user enters start date and end date. I
will use text boxes for both dates.

How can I format so user does not have to enter slashes and it display in
date format? ie. 01/01/2007.

Thank you.



Aug 16 '07 #4
Mehbs wrote:
Thanks guys.

Now how do I get rid of time. I just need the date.
For example my dateticket name is dtperiod. When I try to display dtperiod,
it displays date and time.
How are you displaying it? If you use DateTime.ToShortDateString, that
should do it. Or pass in a custom format to ToString. Ex:

Console.WriteLine (dtperiod.ToString("dd-MM-yyyy"));

If you want just the date component you can access dtperiod.Date. Note
that it will still contain the time elements but they will be set to
00:00:00.
--
Tom Porterfield
Aug 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Kuhn | last post by:
I have a query with a date field criteria of: Between And When the query is run, I am asked for the Start date and then the End Date. So far, so good. The records returned are all those in...
0
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The...
5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
2
by: Cindy | last post by:
Hi all you smarties out there, I'm having a little conundrum with my asp.net page Scenario: I have a form (asp.net) with no code behind (as yet). I have placed a javascript function on a...
3
by: markaelkins | last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am basically trying to send an ID variable into sql to return different records. I've searched everywhere and cannot find the...
9
by: VJ | last post by:
I have a window were I display a bunch of Labels. A click event is attached for each label, when clicked it will display a edit box i.e textbox. If the enter key is pressed in the textbox I want to...
3
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript...
15
by: Mr.Tom.Willems | last post by:
Hello people, I am ussing an MS access database to enter and manage data from lab tests. until now i was the only one handeling the data so i had no need for a controle on how missing data was...
6
by: Mark B | last post by:
I have a function that looks up a SQL table to see if a search term matches. It works fine but so far there are two things yet to work: 1) After entering a search term and pressing Enter, nothing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.