Navi
10-28-2006, 05:07 PM
Hi! I create textbox and need to enter date into it using asp.net. If I enter 092006 press enter, the number will change to 09/20/2006. How to code this? Thanks in advance!
|
Click to See Complete Forum and Search --> : Date format and search date Navi 10-28-2006, 05:07 PM Hi! I create textbox and need to enter date into it using asp.net. If I enter 092006 press enter, the number will change to 09/20/2006. How to code this? Thanks in advance! Chitra Xavier 10-30-2006, 05:44 AM Hi Navi, Use Convert.ToDateTime() to change the string to mm/dd/yyyy format. Note that for the above function to execute it needs the input in 09/20/06 rather than 092006 . To pass the right input use string insert function as Dim input As String = "092006".Insert(2, "/").ToString.Insert(5, "/").ToString Me.txtbox.Text=Convert.ToDateTime(input) u will get the answer. Navi 10-30-2006, 10:09 AM Thanks! Chitra, I don't want the date as 092006, if use enter any date, it will change to the date format, how to do it? Thanks! EvoMage 10-30-2006, 05:24 PM Hi Navi, try DateTime dt = DateTime.parse(datestring); Evo Chitra Xavier 10-30-2006, 11:47 PM Hi Navi, I think u need to convert to datetime as u enter in textbox,then use the code followed down. private void textBox5_TextChanged(object sender, EventArgs e) { if (this.textBox5.Text.Length > 7) { this.textBox5.Text = Convert.ToDateTime(this.textBox5.Text.ToString()).ToString(); } } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |