Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how disable date greater than current date ajax CalendarExtender.
Posted
Updated 20-May-13 3:21am
v4
Comments
navin ks 20-May-13 6:53am    
remove end date tag. by default its todays date or try enddate="CURDATE()"
Thanks7872 20-May-13 6:58am    
You can do such that it gives alert when user selects date greater than today's date.If you want to do so,let me know.
[no name] 20-May-13 7:00am    
ok tell me how ?

1 solution

Refer to below link

ASP.NET AJAX Calendar Extender – Tips and Tricks

The code you want is stated in that article as follows:

C#
<head runat="server">
    <title>Calendar Extender</title>
    <script type="text/javascript">
    function checkDate(sender,args)
{
 if (sender._selectedDate > new Date())
            {
                alert("You cannot select a day earlier than today!");
                sender._selectedDate = new Date(); 
                // set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
}
    </script>
</head>
Call the code:
   <form id="form1" runat="server">
        <asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown" />
        <div>
          
            <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
            <cc1:calendarextender id="CalendarExtender1" xmlns:cc1="#unknown">
            runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />
 
        </cc1:calendarextender></div>
    </form>


Also you can find one more example on this link

Disable dates in Ajax CalendarExtender
 
Share this answer
 
v2

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