1
後,我有initiaized如下內嵌的DatePicker(周-選擇器),其在選擇觸發一個ASP.NET Click事件。它的功能很好,我的ASP代碼它的一部分,但是如果我選擇日期爲前:由DatePicker的的下一個/上一個按鈕推進月,當頁面回發後刷新之後,DatePicker的返回到當前月...還它會在這裏失去selectCurrentWeek()方法中選定的startDate/endDate Range。JQuery用戶界面內嵌的DatePicker失去日期ASP.NET回發
var startDate;
var endDate;
var selectCurrentWeek = function() {
window.setTimeout(function() {
$('.week-picker').find('.ui-datepicker-current-day a').addClass('ui-state-active')
}, 1);
}
$('.week-picker').datepicker({
showOtherMonths: true,
selectOtherMonths: true,
firstDay: 1,
onSelect: function (dateText, inst) {
var date = $(this).datepicker('getDate');
startDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay() + 1);
endDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay() + 6);
var dateFormat = inst.settings.dateFormat || $.datepicker._defaults.dateFormat;
$('#txtDP1').val($.datepicker.formatDate(dateFormat, date, inst.settings));
selectCurrentWeek();
DP1_Submit();
},
beforeShowDay: function (date) {
var cssClass = '';
if (date >= startDate && date <= endDate)
cssClass = 'ui-datepicker-current-day';
return [true, cssClass];
},
onChangeMonthYear: function (year, month, inst) {
selectCurrentWeek();
}
});
$('.week-picker .ui-datepicker-calendar tr').live('mousemove', function() { $(this).find('td a').addClass('ui-state-hover'); });
$('.week-picker .ui-datepicker-calendar tr').live('mouseleave', function() { $(this).find('td a').removeClass('ui-state-hover'); });
隱藏字段/按鈕是:
<asp:TextBox ID="txtDP1" runat="server" style="display:none;" />
<asp:Button ID="btnDP1" runat="server" Text="Go" style="display:none;" />
我已經採用的setDate()方法嘗試過,和沒有成功defaultDate屬性。幫幫我?
如果你想你可以改變屬性id爲hdnDp1,也可以改變jQuery和.cs頁面。 – Thulasiram
remove style =「display:none;」並檢查值是在回發 – Thulasiram