if i select a date in the ajax calendar extender control and then edit the textbox associated with the calendar control to another date (say diff date, diff year, month than the one i selected using the calendar), my code below (in textbox onblur or clientshowing
event of calendar) selects the date in the calendar based on the textbox but doesnt move the calendar view to that date, it still shows the visible date of calendar to the one that i selected using the calendar control.
for e.g. i selected 01/01/2011 in the calendar and it populates this date to textbox then edited to 02/15/2015 (diff date,month,year compared to what i selected) and then i move to diff control and when i came to the textbox, the calendarextender pops up
with 01/01/2011 (shows jan 2011 month instead of feb 2015). if i manally click the feb 2015 then i can see the 02/15/2015 date is selected and highlighted.
so i set the edited text to even the visible date property (or method) and also using switchmonth method but still not switching (or setting) the visible month and year to the date i edited eventhough it is selected.
i wroted the following js code after setting the selected date:
cal._visibleDate=dt; //where dt is the date that i entered in the date textbox
cal.set_visibleDate(dt);
cal._switchMonth(dt);
cal.set_switchMonth=dt.getMonth()+1;
still not working but if i call the above code in clientshown event instead of clientshowing event of calendarextender, sometimes it works but i can visually see the date moving to the target date in the calendar which is not good eventhough it is working as
i written it in clientshown event.
not sure why the visible month, year of the calendar nt set to the selected date (which is set through code) in clientshowing event or textbox onblur event. any idea.
arnet
Member
54 Points
59 Posts
set visible date of ajax calendarextender control based on textbox entry
May 05, 2011 04:32 PM|LINK
if i select a date in the ajax calendar extender control and then edit the textbox associated with the calendar control to another date (say diff date, diff year, month than the one i selected using the calendar), my code below (in textbox onblur or clientshowing event of calendar) selects the date in the calendar based on the textbox but doesnt move the calendar view to that date, it still shows the visible date of calendar to the one that i selected using the calendar control.
for e.g. i selected 01/01/2011 in the calendar and it populates this date to textbox then edited to 02/15/2015 (diff date,month,year compared to what i selected) and then i move to diff control and when i came to the textbox, the calendarextender pops up with 01/01/2011 (shows jan 2011 month instead of feb 2015). if i manally click the feb 2015 then i can see the 02/15/2015 date is selected and highlighted.
so i set the edited text to even the visible date property (or method) and also using switchmonth method but still not switching (or setting) the visible month and year to the date i edited eventhough it is selected.
i wroted the following js code after setting the selected date:
cal._visibleDate=dt; //where dt is the date that i entered in the date textbox
cal.set_visibleDate(dt);
cal._switchMonth(dt);
cal.set_switchMonth=dt.getMonth()+1;
still not working but if i call the above code in clientshown event instead of clientshowing event of calendarextender, sometimes it works but i can visually see the date moving to the target date in the calendar which is not good eventhough it is working as i written it in clientshown event.
not sure why the visible month, year of the calendar nt set to the selected date (which is set through code) in clientshowing event or textbox onblur event. any idea.
thanks for all your help.
DarrellNorto...
All-Star
86809 Points
9646 Posts
Moderator
MVP
Re: set visible date of ajax calendarextender control based on textbox entry
May 05, 2011 05:35 PM|LINK
Just use the jQuery DatePicker. It has built-in support for what you want.
See here, just change the date in the textbox and the selected date automatically updates in the calendar: http://jqueryui.com/demos/datepicker/
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: set visible date of ajax calendarextender control based on textbox entry
May 06, 2011 03:29 AM|LINK
Hi, Please refer this
http://forums.asp.net/t/1093475.aspx/1
http://weblogs.asp.net/rajneesh-verma/archive/2011/02/26/read-only-textbox-for-calendar-extender.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
serkansendur
Member
50 Points
57 Posts
Re: set visible date of ajax calendarextender control based on textbox entry
Apr 16, 2012 07:00 PM|LINK
I was able to do it as follows :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> function AddCalendars() { //The last parameter should be the TargetControl's id. If you use "TextBox1", the TextBox1 would be associated. var elem = $(".deneme"); for (var a = 0; a < elem.length; a++) { if ($find("CalendarExtender" + elem[a].id)) { $find("CalendarExtender" + elem[a].id).dispose(); } } for (var i = 0; i < elem.length; i++) { $create(AjaxControlToolkit.CalendarBehavior, { "id": "CalendarExtender" + elem[i].id }, null, null, elem[i]); } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <%--the dummy calendar which is used to download the related script file.--%> <asp:TextBox ID="dummyTextBox" runat="server" Style="display: none"></asp:TextBox> <AjaxControlToolkit:CalendarExtender ID="dummyCalendarExtender" runat="server" Enabled="True" TargetControlID="dummyTextBox"> </AjaxControlToolkit:CalendarExtender> <%--the dummy calendar which is used to download the related script file.--%> <asp:Button ID="Button1" OnClientClick="AddCalendars();return false" runat="server" Text="CreateCalendarFromClient" /><br /> input:<input id="deneme1" type="text" class="deneme" /><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> TextBox: <asp:TextBox ID="deneme2" runat="server" cssclass="deneme" ClientIDMode="Static"></asp:TextBox> </div> </form> </body> </html>