本文介绍了为什么我收到字符串未被识别为有效的日期时间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有jquery日期选择器的文本框txtChqDate。如果日期少于今天的日期(2016-11-10)被选中而不是它的罚款但是日期大于今天日期说(2016-11-26)被选中而不是它显示错误字符串未被识别为有效日期时间。



我尝试过:



我用过的代码:



DateTime chqdate = Convert.ToDateTime(txtChqDate.Text);

DateTime transdate = Convert.ToDateTime(txtTransDate.Text);

if(chqdate> transdate)

{

string script =alert('Check Date未到达');;

ClientScript.RegisterClientScriptBlock(this.GetType(),Alert;, script,true);

txtChqDate.Text =

txtAccNo.Focus();

}

其他

{

txtpaidto。焦点();

}

解决方案

I have a textbox txtChqDate having jquery date picker.If date less than todays date(2016-11-10) is selected than its fine but date greater than todays date say(2016-11-26) is selected than it shows error "String was not recognized as a valid DateTime".

What I have tried:

Code I have used:

DateTime chqdate = Convert.ToDateTime(txtChqDate.Text);
DateTime transdate = Convert.ToDateTime(txtTransDate.Text);
if (chqdate >transdate)
{
string script ="alert('Cheque Date Not Reached');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert";, script, true);
txtChqDate.Text =""
txtAccNo.Focus();
}
else
{
txtpaidto.Focus();
}

解决方案



这篇关于为什么我收到字符串未被识别为有效的日期时间。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:06