Answered by:
Ajax Calendar Extender

Question
-
User-1664485818 posted
Hi folks, is it possible to set the calendar to display advance dates only i.e. 2 days from present date.
Example if today’s date was 04/10/2014, the calendar would only display dates from 07/10/2014 onwards. Calendar code below;
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager> <asp:CalendarExtender ID="CalendarExtender2" TargetControlID="txtFittingDate" runat="server" Format="dd/MM/yyyy"></asp:CalendarExtender>
Thursday, December 4, 2014 6:03 AM
Answers
-
User724169276 posted
ops..remove the internal specifier:
protected override void OnInit(EventArgs e) { base.OnInit(e); //set the validator min and max values this.CalenderExtender2.StartDate=DateTime.Today.AddDays(2); }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 4, 2014 6:42 AM
All replies
-
User724169276 posted
Hello,
Override the Init event of page class and set the Minimum and Maximum date for the calender:
protected internal override void OnInit(EventArgs e) { base.OnInit(e); //set the validator min and max values this.CalenderExtender2.MinimumValue = DateTime.Today.Date.AddDays(2).ToShortDateString(); }
EDIT: Provided links.
Thursday, December 4, 2014 6:09 AM -
User-1664485818 posted
Hi Ashim, how do I Override the Init event of page class and set the Minimum and Maximum date for the calender?
Still learning
Thursday, December 4, 2014 6:18 AM -
User724169276 posted
how do I Overridei just gave you the code .. copy it and paste it in your page's codebehind where other events like Page_Load resides.Thursday, December 4, 2014 6:20 AM -
User-1664485818 posted
Pasted your code, receiving the following error message;
Error AjaxControlToolkit.CalendarExtender' does not contain a definition for 'MinimumValue' and no extension method 'MinimumValue' accepting a first argument of type 'AjaxControlToolkit.CalendarExtender' could be found (are you missing a using directive or an assembly reference?)
Thursday, December 4, 2014 6:24 AM -
User724169276 posted
brucey
Error AjaxControlToolkit.CalendarExtender' does not contain a definition for 'MinimumValue' and no extension method 'MinimumValue' accepting a first argument of type 'AjaxControlToolkit.CalendarExtender' could be found (are you missing a using directive or an assembly reference?)Oh sorry .. the property is StartDate.
protected internal override void OnInit(EventArgs e) { base.OnInit(e); //set the validator min and max values this.CalenderExtender2.StartDate=DateTime.Today.AddDays(2).ToShortDateString(); }
Thursday, December 4, 2014 6:30 AM -
User-1664485818 posted
Hi Ashim, new error message
"Cannot implicitly convert type 'string' to 'System.DateTime"
Thursday, December 4, 2014 6:33 AM -
User724169276 posted
brucey
"Cannot implicitly convert type 'string' to 'System.DateTime"i was expecting that .. :D , here we go.
protected internal override void OnInit(EventArgs e) { base.OnInit(e); //set the validator min and max values this.CalenderExtender2.StartDate=DateTime.Today.AddDays(2); }
Thursday, December 4, 2014 6:34 AM -
User-1664485818 posted
New error
Pages_CustomerOrder.OnInit(System.EventArgs)': cannot change access modifiers when overriding 'protected' inherited member 'System.Web.UI.Control.OnInit(System.EventArgs)'
Thursday, December 4, 2014 6:38 AM -
User724169276 posted
ops..remove the internal specifier:
protected override void OnInit(EventArgs e) { base.OnInit(e); //set the validator min and max values this.CalenderExtender2.StartDate=DateTime.Today.AddDays(2); }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 4, 2014 6:42 AM -
User-1664485818 posted
Hi Ashim, my fault your code is working fine, is it possible to hide these dates from the calendar picker? At the moment the dates are just scored out
Thursday, December 4, 2014 6:45 AM -
User724169276 posted
is it possible to hide these dates from the calendar picker?I think its possible , try to change the css for invalid dates like below:
.cal_Calendar .ajax__calendar_invalid .ajax__calendar_day /* Add class for your Invalid dates*/ { display:none; // this should work , however its untested }
Thursday, December 4, 2014 6:49 AM -
User-1664485818 posted
Is it possible to set focus to the next available date?
Thursday, December 4, 2014 6:50 AM -
User724169276 posted
Is it possible to set focus to the next available date?
set the text property of the textbox for the calender extender.
Thursday, December 4, 2014 6:52 AM -
User-1664485818 posted
eh where is the css for the AJAX calendar?
Thursday, December 4, 2014 6:55 AM -
User724169276 posted
where is the css for the AJAX calendar?it comes up out of the box with the ajax package AFAIK.
Thursday, December 4, 2014 6:57 AM -
User724169276 posted
If it helps.Mark the post(s) and close the thread.
Thursday, December 4, 2014 7:07 AM -
User-1664485818 posted
Thanks Ashim much appreciated
Thursday, December 4, 2014 7:08 AM