Hi
I have 2 webdate choosers in a page namely start date , end date. When the first time page loads start date highlights current date, month dropdown shows current month and year dropdown shows current year. First I changed the month to "March" and year to "2007". Then I have a button reset, there I set the value to null in server side as given below.
wbchStart.Value = null;
Using javscript in another page
Now the start date month, year dropdowns shows the value selected previously(March,2007). Same case for end date also. But I want to reset the month, year dropdowns to what it is displayed(September,2009) while pageload. I want the solution to reset in javascript also.
How can I do this? I am using c#. I have posted the code below. Let me know if you need any more information. I need immediate help in this regard. Thanks in advance.
<igsch:WebDateChooser Width="90px" ID="wbchStart" Section508Compliant ="true" runat="server" NullDateLabel="MM/DD/YYYY" CssClass ="date"> <ClientSideEvents InitializeDateChooser="InitProjectStartDateChooser" /></igsch:WebDateChooser >
function ResetDate() {
oStartTimeGenDateCt4.setValue(
null);
}
Hi Sridhar,
I saw your codes, which set null to WebDateChooser, so I assumed that you want to reset (clear up) value in control.
If under reset you mean setting current current date instead of null, then you should use "new Date()" on client and "DateTime.Now", or "DateTime.Today", or "new DateTime()" on server. If you need to "reset" dateChooser on every load, then there is no need to do that on client and to process ClientSideEvents.InitializeDateChooser. It is enough to
protected void Page_Load(object sender, EventArgs e){ this.WebDateChooser1.Value = DateTime.Now;}
If you do that, then you do not need any server "reset " button. Though you may have reset button and within its click handler do exactly the same:
protected void ServerReset_Click(object sender,EventArgs e){ this.WebDateChooser1.Value = DateTime.Now;}
If you set value in WebDateChooser on client to current date, then drop-down will show current date too. If you set null to WebDateChooser on client, then to adjust visible date in drop-down calendar, you may use "Calendar" member variable.
function resetDateChooser(oDateChooser){ oDateChooser.setValue(new Date()); // null oDateChooser.Calendar.setVisibleMonth(new Date());}
Hi Viktor,
Thanks. This is what I want.
Sridhar