Click here to Skip to main content
15,902,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is what I have written in .asp file.. it gives error like converting to date time....

C#
<asp:TextBox ID="inputDate" runat="server" ClientIDMode="Static"
 CssClass="inputDate regitextbox" value="06/14/2008"></asp:TextBox>


in cs file i wrote...


C#
var date = inputDate.Text.Trim();
  var da = Convert.ToDateTime(date);



it gives following error..



Quote:
String was not recognized as a valid Date Time.
Posted

1 solution

C#
string format = "MM/dd/yyyy"
string dateTime = "06/14/2008";
DateTime.ParseExact(dateTime ,format,CultureInfo.InvariantCulture);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900