Problema: per JQuery CalendarExtender priskirti datos reikšmę taip, kad ir TextBox'e, ir kalendoriuje matytųsi teisinga data.
Sprendimas: Firstly you need to ensure that the Calendar Extender, as seen below in Figure 1, has a BehaviorID value set.
< asp : TextBox ID="dateLastCheckedTextBox" runat="server" CssClass="textBox" / >
< asp : CalendarExtender id="dateLastCheckedCalendarExtender" BehaviorID="dateLastCheckedCalendarExtender" runat="server" TargetControlID="dateLastCheckedTextBox" Format="dd/mm/yyyy" EnabledOnClient="true" OnClientShown="checkDate" / >
function checkDate(sender, args) {
var currentDate = $("input[id$='dateLastCheckedTextBox']:visible").val();
var calendarBehavior = $find("dateLastCheckedCalendarExtender");
calendarBehavior.set_selectedDate(getDateFromUkDateString(currentDate));
}
function getDateFromUkDateString(dateStr) {
dateStr = dateStr.split("/");
if (dateStr.length == 1)
return null;
else
return new Date(dateStr[2], dateStr[1] – 1, dateStr[0]);
}
http://gordonduthie.net/2010/04/14/setting-the-value-of-a-calendarextender-using-jquery/
var currentDate = $("input[id$='dateLastCheckedTextBox']:visible").val();
var calendarBehavior = $find("dateLastCheckedCalendarExtender");
calendarBehavior.set_selectedDate(getDateFromUkDateString(currentDate));
}
function getDateFromUkDateString(dateStr) {
dateStr = dateStr.split("/");
if (dateStr.length == 1)
return null;
else
return new Date(dateStr[2], dateStr[1] – 1, dateStr[0]);
}
http://gordonduthie.net/2010/04/14/setting-the-value-of-a-calendarextender-using-jquery/
Komentarų nėra:
Rašyti komentarą