Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
When user select a date using calender-extender It should add 5years to the selected date and then display.
The code is working. But the month is not displaying. Please help me to solve this.
//==================================================
XML
<script type ="text/javascript" >
   function dateSelectionChanged(sender, args) {
     var  dt1 = sender.get_selectedDate();
     dt1.setYear(dt1.getYear() + 5);
     var dt2 = dt1.format("dddd, mmmm d, yyyy");
     document.getElementById('TextBox1').value = dt2;
 }
 </script>

//====================================================
XML
<cc1:ToolkitScriptManager ID="sksk" runat ="server" ></cc1:ToolkitScriptManager>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      <cc1:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
            Enabled="True" TargetControlID="TextBox1"
            OnClientDateSelectionChanged="dateSelectionChanged" >
      </cc1:CalendarExtender>
Posted

1 solution

Replacing JavaScipt
//===================

XML
<script type ="text/javascript" >
  function dateSelectionChanged(sender, args) {
    var  dt1 = sender.get_selectedDate();
    dt1.setMonth(dt1.getMonth() + 5);
    var dt2 = dt1.format("dd, MM , yyyy");
    document.getElementById('TextBox1').value = dt2;
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900