I have a button in my page. When I click it, it should open a JQuery window.
Inside the window, I have a datepicker control, which by default should show the current date. My code is like so.
CLIENT SIDE
<script type="text/javascript">
$(function () {
$("#<%= txtDate.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '1901:2050',
maxDate: new Date(),
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
showButtonPanel: true,
showMonthAfterYear: true,
inline: true,
altField: "#<%= HiddenDate.ClientID %>",
altFormat: "dd-mm-yy",
onSelect: function (dateText, inst) {
shouldsubmit = true;
},
onClose: function (dateText, inst) {
shouldsubmit = false;
javascript: __doPostBack('<%= txtDate.ClientID %>', '');
}
});
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function (evt, args) {
$("#<%= txtDate.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '1901:2050',
maxDate: new Date(),
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
showButtonPanel: true,
showMonthAfterYear: true,
inline: true,
altField: "#<%= HiddenDate.ClientID %>",
altFormat: "dd-mm-yy",
onSelect: function (dateText, inst) {
shouldsubmit = true;
},
onClose: function (dateText, inst) {
shouldsubmit = false;
javascript: __doPostBack('<%= txtDate.ClientID %>', '');
}
});
});
SERVER SIDE
If Not Page.IsPostBack Then
TxtDate.Text = DateTime.Today.ToString("dd-MM-yyyy")
TxtDate.Text = Session("CurrentDate")
End If
But the textbox remains blank. Any clues as to where I am wrong?