473,698 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5087
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*****@comcas t.netwrote in message
news:uf******** ******@TK2MSFTN GP06.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******** ********@TK2MSF TNGP05.phx.gbl. ..
Hi,

You better use the DateTimePicked and/or maskedTextBox

"Mehbs" <ms*****@comcas t.netwrote in message
news:uf******** ******@TK2MSFTN GP06.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.ToShor tDateString, that
should do it. Or pass in a custom format to ToString. Ex:

Console.WriteLi ne (dtperiod.ToStr ing("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
15945
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 between those dates and not records that are on the start or the end date. For example, I enter "09/01/03" for the start date and "09/30/03" for
0
1702
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 numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset xml these numbers are defined as decimal. I am using the binding method Format to display the data in scientific notation and Parse to...
5
6819
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 rather than actually clicking the search button, but this does not run the search code behind the button.
2
7190
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 server side textbox control to do something - eg change the words on label - when the key pressed is the "enter" key. I can see the label change to what i expect ----- BUT .... then the
3
1835
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 answer. I'd appreciate and help. Thanks. What I'm doing is creating a treeview with the structure as follows (this is the expanded view): - Item Status - Item Status Details
9
430
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 the foucs to shift to the next label in taborder and then fire the click event of that label and display a editbox. Here is what I tried..and its not working.. The current edit box has a key down event.. with code like this.. If e.KeyCode =...
3
4494
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 that will do this? Also, how can I add a button to a form to enter a NULL. Thanks in advance.
15
12103
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 entered, since i did it myself i knew exactly what data was missing... The problem is that i can have data that hasn't been enterd yet, or data that is below detection level(so missing).
6
3588
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 has been happening. It has only been searching when I click the Search button. 2) Neither of the Response.Write's have been displaying any text. Here's the code:
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.