Hi,
I am passing Date as "04/15/2014" on click of Calender Selected Change to text box. In my Code behind File i am making
if(txtDate.text=="")
{
value=
//I am not getting what to assign
}
else
{
value=DatetTime.Parse(txtDate.text);
//This is giving error as "Error: Sys.WebForms.PageRequestManagerServerErrorException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0."
}
please help me with this issue.
Regards,
Sivapratap
Khan Abrar AhmedPosted Apr 15, 2014, 4:33 AM
you can try this.
DateTime value ;
if(!string.isnullorEmpty(txtDate.text))
{
value = Convert.TodateTime(txtDate.text);
}
else
{
value =DateTime.Now;
}
Jignesh TrivediPosted Apr 15, 2014, 6:33 AM
hi,
you can use DateTime.TryParseExact method if you date picker has specific type of format
DateTime dt = DateTime.Now;
if(!string.isnullorEmpty(txtDate.text))
{
DateTime.TryParseExact(txtDate.text, "MM/dd/yyyy", new System.Globalization.CultureInfo("en-US"), System.Globalization.DateTimeStyles.None, out dt);
}
hope this will help you.