<ajaxToolkit:CalendarExtender ID="calDisplaydate" ... OnClientShowing="setDate"
BehaviorID="myDate">
</ajaxToolkit:CalendarExtender>
In javascript:
<script type="text/javascript" language="javascript">
function setDate(sender,args){
var d = new Date(); //Today
d.setMonth(d.getMonth() - 1); //1 month ago
$find("myDate").set_selectedDate(d);
}
</script>
Just used a js-debugger to see what properties and functions a CalendarExtender
has on clientside. Two interesting things found, the
OnClientShown
event and the
set_visibleDate
function:
<script type="text/javascript">
function ApplyStartMonth(sender, args) {
var calendarStart = $find('CalendarExtender1');
sender.set_visibleDate(calendarStart._selectedDate);
// the following is not needed here but good to know that they exist
//sender.set_todaysDate(calendarStart._selectedDate);
//sender.set_selectedDate(calendarStart._selectedDate);
}
</script>
<asp:TextBox ID="TxtStart" runat="server" Text="22.03.2012"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd.MM.yyyy" TargetControlID="TxtStart" /><br />
<asp:TextBox ID="TxtEnd" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd.MM.yyyy"
OnClientShown="ApplyStartMonth" TargetControlID="TxtEnd" />
<ajaxToolkit:CalendarExtender ID="calDisplaydate" ... OnClientShowing="setDate"
BehaviorID="myDate">
</ajaxToolkit:CalendarExtender>
In javascript:
<script type="text/javascript" language="javascript">
function setDate(sender,args){
var d = new Date(); //Today
d.setMonth(d.getMonth() - 1); //1 month ago
$find("myDate").set_selectedDate(d);
}
</script>
This works but only problem is that I dont want the textbox to have the date filled when the calendar is opened unless I clicked on Date I need to go in textbox...
This works but only problem is that I dont want the textbox to have the date filled when the calendar is opened unless I clicked on Date I need to go in textbox...
saqib_dotnet
Member
298 Points
650 Posts
display selected month in calendarextender
Nov 29, 2012 05:13 PM|LINK
Hi,
I need to show 1 month old 'month/date' in calendar when user clicks on it from today.
Any suggestions please.
thanks,
msmk
Participant
797 Points
180 Posts
Re: display selected month in calendarextender
Nov 29, 2012 05:38 PM|LINK
Try this code:
<ajaxToolkit:CalendarExtender ID="calDisplaydate" ... OnClientShowing="setDate" BehaviorID="myDate"> </ajaxToolkit:CalendarExtender> In javascript: <script type="text/javascript" language="javascript"> function setDate(sender,args){ var d = new Date(); //Today d.setMonth(d.getMonth() - 1); //1 month ago $find("myDate").set_selectedDate(d); } </script>RameshRajend...
Star
7983 Points
2099 Posts
Re: display selected month in calendarextender
Nov 29, 2012 05:42 PM|LINK
selecting particular month as default in calendar extender:
Just used a js-debugger to see what properties and functions a CalendarExtenderhas on clientside. Two interesting things found, the event and the function:<script type="text/javascript"> function ApplyStartMonth(sender, args) { var calendarStart = $find('CalendarExtender1'); sender.set_visibleDate(calendarStart._selectedDate); // the following is not needed here but good to know that they exist //sender.set_todaysDate(calendarStart._selectedDate); //sender.set_selectedDate(calendarStart._selectedDate); } </script> <asp:TextBox ID="TxtStart" runat="server" Text="22.03.2012"></asp:TextBox> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd.MM.yyyy" TargetControlID="TxtStart" /><br /> <asp:TextBox ID="TxtEnd" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd.MM.yyyy" OnClientShown="ApplyStartMonth" TargetControlID="TxtEnd" />How to show and select month/year in Calendar Extender
http://geekswithblogs.net/aghausman/archive/2009/05/31/how-to-show-and-select-monthyear-in-calendar-extender.aspx
saqib_dotnet
Member
298 Points
650 Posts
Re: display selected month in calendarextender
Nov 29, 2012 09:58 PM|LINK
This works but only problem is that I dont want the textbox to have the date filled when the calendar is opened unless I clicked on Date I need to go in textbox...
What property need to be set for that?
chetan.sarod...
All-Star
66639 Points
11275 Posts
Re: display selected month in calendarextender
Nov 30, 2012 02:39 AM|LINK
Refer this thread -
http://forums.asp.net/p/1621613/4163864.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
RameshRajend...
Star
7983 Points
2099 Posts
Re: display selected month in calendarextender
Nov 30, 2012 04:20 AM|LINK
Please look this
http://weblogs.asp.net/aghausman/archive/2009/05/31/how-to-show-and-select-month-year-in-calendar-extender.aspx
http://www.aspdotnet-suresh.com/2012/06/ajax-calendar-extender-control-example.html