fable fable - 1 year ago 107
ASP.NET (C#) Question

string was not recognized as a valid datetime after added datetimepicker

I have an error "string was not recognized as a valid datetime". I took this error when add "datetimepicker" in my project.
How can I solve this? I tried other solutions but didn't help.

Datetime garanti_baslangici = DateTime.Parse(
GarantiBaslangici.Text, System.Globalization.CultureInfo.InvariantCulture);

.aspx code

<asp:TextBox ID="GarantiBaslangici" CssClass="datepicker" runat="server" />

Answer Source

Try just parse string, it should parse right according to the current system format.

Datetime garanti_baslangici=DateTime.Parse(GarantiBaslangici.Text) 

or better

Datetime garanti_baslangici;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download