JQuery DatePicker 未在部分回发时保存正确的日期
所以我有一些文本框(在用户控件中 ModalPopup 的 UpdatePanel 中)如下所示:
<asp:TextBox ID="exampleTextBox" runat="server" MaxLength="10"
CssClass="datepicker" ReadOnly=true
Text='<%# Bind("ExampleDateField") %>' Width="77px">
</asp:TextBox>
我还有一些 jQuery(从母版页上的文件导入),它们连接 jQuery DatePickers,如下所示:
function pageLoad() {
$(".datepicker").unbind();
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
beforeShowDay: $.datepicker.noWeekends,
showOn: 'button',
buttonImage: '../Resources/Images/Calendar_scheduleHS.gif',
buttonImageOnly: true,
buttonText: 'Select a Date'
});
}
DatePickers 显示正确,即使在回发之后。
问题是发生回发时文本框的值不会更改。这很奇怪,因为文本框显示了浏览器中选定的日期。但是,文本框的值仍然是文本框最初具有的日期,而不是从日期选择器中选择的日期。
有什么想法为什么我无法获得选定的日期吗?
So I have some textboxes (in an UpdatePanel in a ModalPopup in a User Control) that look like this:
<asp:TextBox ID="exampleTextBox" runat="server" MaxLength="10"
CssClass="datepicker" ReadOnly=true
Text='<%# Bind("ExampleDateField") %>' Width="77px">
</asp:TextBox>
I also have some jQuery (imported from file on the Master page) that hooks up the jQuery DatePickers like so:
function pageLoad() {
$(".datepicker").unbind();
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
beforeShowDay: $.datepicker.noWeekends,
showOn: 'button',
buttonImage: '../Resources/Images/Calendar_scheduleHS.gif',
buttonImageOnly: true,
buttonText: 'Select a Date'
});
}
The DatePickers appear correctly, even after a postback.
The problem is that the value of the textboxes is not changed when a postback occurs. This is very odd since the textbox shows the selected date in the browser. However, the value of the textbox is still the date that the textbox originally had, not the date selected from the datepicker.
Any ideas why I cannot get the selected date?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是由于
ReadOnly=true
属性造成的。把它去掉,或者设置为 false 那么它将使用发布的值
It is due to the
ReadOnly=true
attribute.Take that off, or set to false then it will use the posted value