I'm using Microsoft Visual Studio and Microsoft SQL Server Management for this.
I implemented a text box with a calendar extender.
What I'm trying to do is to disable the date before TODAY, for example, unclickable.
I found some searches on google. And they are giving me java scripts.
How do I implement this java scripts onto my visual studio ?
Below is the java script:
<div>
<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" />
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1"
runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />
</div>
</form>
Can you provide the code you placed in your .aspx and also in your page load. so that we can understand exactly what code you have placed and if not me, some one else will be able to assist you with this problem.
ThePotatoMan
Member
2 Points
2 Posts
Ajax Control Calendar Extender
Feb 10, 2012 09:43 AM|LINK
I'm using Microsoft Visual Studio and Microsoft SQL Server Management for this.
I implemented a text box with a calendar extender.
What I'm trying to do is to disable the date before TODAY, for example, unclickable.
I found some searches on google. And they are giving me java scripts.
How do I implement this java scripts onto my visual studio ?
Below is the java script:
<div><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" /> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" /> </div> </form></div>avinash_bhud...
Contributor
2881 Points
517 Posts
Re: Ajax Control Calendar Extender
Feb 10, 2012 09:50 AM|LINK
May be this link will help you.
http://tonesdotnetblog.wordpress.com/2009/04/15/how-to-patch-the-ajax-control-toolkit-calendarextender-to-add-decade-support-and-initialview-part-1/
swapna.anu
Contributor
2658 Points
746 Posts
Re: Ajax Control Calendar Extender
Feb 10, 2012 09:51 AM|LINK
Hi
I can see the code you provided in the below link
http://stackoverflow.com/questions/5608062/how-to-disable-previous-dates-in-calendarextender-control-through-its-render-eve
It also provides another method using compare validator to your calendar extender.
Why don't you want to use that.
Thanks.
ThePotatoMan
Member
2 Points
2 Posts
Re: Ajax Control Calendar Extender
Feb 10, 2012 10:18 AM|LINK
I referred and tried out the validators
However, it returned me with error messages with ANY dates I cicked on.
Help ?
I used 7 days limit. The picture below will show that it didn't work.
swapna.anu
Contributor
2658 Points
746 Posts
Re: Ajax Control Calendar Extender
Feb 10, 2012 11:30 AM|LINK
Hi,
Can you provide the code you placed in your .aspx and also in your page load. so that we can understand exactly what code you have placed and if not me, some one else will be able to assist you with this problem.
Thanks,
Swapna
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Ajax Control Calendar Extender
Feb 13, 2012 03:02 AM|LINK
Hello
You may try StartDate property. So at code behind, Page_Load, try
CalendarExtender1.StartDate = DateTime.Now;
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
deepakdeligh...
Member
20 Points
6 Posts
Re: Ajax Control Calendar Extender
Feb 24, 2012 03:00 PM|LINK
The StartDate property for CalendarExtender is not available with my AJAX Extender .Why?