我必须保存从ajax日历控件中选择的日期,当我从ajax日历控件中选择日期时,它会显示在文本框中,但是当我保存此日期时,我得到的是日期的前一个值,而不是经过精心选择的值,因此我已编写此代码关于btnsave_Click事件
我的.CS代码如下:
protected void btnsave_Click(object sender, EventArgs e)
{
DateTime bdate = DateTime.ParseExact(txtBirthDate.Text, "dd/MM/yyyy", null);
}
我的.aspx日历控制代码:
<td>
<asp:TextBox ID="txtBirthDate" runat="server" ReadOnly="true" CssClass="Txtprop" ></asp:TextBox>
<cc1:CalendarExtender ID="calDOB" runat="server" TargetControlID="txtBirthDate" Format="dd/MM/yyyy" ></cc1:CalendarExtender>
</td>
ReadOnly =“ true”。
If TextBox's ReadOnly property is "true", postback data won't be loaded e.g it essentially means TextBox being readonly from server-side standpoint (client-side changes will be ignored). If you want TB to be readonly in the "old manner" use
TextBox1.Attributes.Add("readonly","readonly")
因为不会影响服务器端功能。有关更多信息,请遵循StackoverflowAnswer或TextBox Readonly问题。
<asp:Content>
之前添加此行<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
在<asp:Content
之后添加
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager>