Thanks for your help but I still couldn't get into the right path.
Let me explicate with a little details. I have a general ASP.Net Calendar control and a Link Button below it along with other controls in a page. I would like to know how the under-mentioned cases can be handled with them using javascript without causing the page to postback.
For each case, I hooked up the OnClientClick event of the Link Button with a javascript method that defines what I want to achieve.
The cases along with their methods follow below.
Case 1- When the Link Button is clicked; it will set the selected date of the Calendar to System.DateTime.MinValue.
Example:
function ResetCalendar() {
document.getElementById('<%= Calendar1.ClientID %>').value = System.DateTime.MinValue
return false;
}
Alternatively:
function ResetCalendar() {
document.getElementById('<%= Calendar1.ClientID %>').value = '<%= System.DateTime.MinValue.ToString() %>';
return false;
}
Case 2- When the Link Button is clicked; it will set the selected date of the Calendar to a date of my choice.
Example:
function ResetCalendar() {
var d = new Date();
d.setFullYear(2013, 08, 21);
document.getElementById('<%= Calendar1.ClientID %>').value = d;
return false;
}
Alternatively:
function ResetCalendar() {
var d = new String("08/21/2013")
document.getElementById('<%= Calendar1.ClientID %>').value = d;
return false;
}
Case 3- When the Link Button is clicked; it will clear the selected date of the Calendar.
Example:
function ResetCalendar() {
document.getElementById('<%= Calendar1.ClientID %>').SelectedDates.Clear();
return false;
}
It’s not working at all in any case. No error message is being shown either. The third case even causes a postback.
Hope I could clarify it more this time. Please help in sorting all of them.
Regards!