我正在使用jquery datepicker,在回发后,日期似乎消失了。 我曾尝试在updatepanel中使用datepicker文本(输入),但没有工作
$(function () {
$("#datepicker_From").datepicker({ dateFormat: 'dd-M-yy' });
$("#datepicker_To").datepicker({ dateFormat: 'dd-M-yy' });
});
In UI:
From Date:
<p>
<input type="text" id="datepicker_From" name="txt_Fdatepicker" value="">
</p>
To Date:
<p>
<input type="text" id="datepicker_To" name="txt_Tdatepicker" value="">
</p>
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["FromDate"] =null;
Session["ToDate"] = null;
BindGrid();
}
string fromDate = Request.Form["txt_Fdatepicker"];
string todate = Request.Form["txt_Tdatepicker"];
if (!string.IsNullOrWhiteSpace(fromDate) && !string.IsNullOrWhiteSpace(todate))
{
DateTime app_FromDate = Convert.ToDateTime(fromDate);
DateTime app_ToDate = Convert.ToDateTime(todate);
Session["FromDate"] = app_FromDate;
Session["ToDate"] = app_ToDate;
}
//在会话中分配值,因为它在回发后消失了