How to disable previous dates while using in ajaxToolkit CalendarExtender
标签:
calendarextender
相关问题
- Convert ASP.NET textbox control .text contents to
- String was not recognized as a valid DateTime duri
- Disable dates conditionally with Asp.net Ajax Cale
- Ajax Toolkit ASP.NET (Visual Basic) Not Displaying
- Calendar control is not popping-up when clicked on
相关文章
- String was not recognized as a valid DateTime duri
- Ajax工具包ASP.NET(Visual Basic)中不显示日历(Ajax Toolkit AS
- 它可以添加在Ajax工具包日历延长“无”选项?(It is possible to add '
- Disable dates conditionally with Asp.net Ajax Cale
- Ajax Toolkit ASP.NET (Visual Basic) Not Displaying
- Calendar control is not popping-up when clicked on
- Ajaxcontrolkit calendar control - customisation
- .net Ajax calendarExtender cuts of saturday's
Following link might help you: Disable dates in CalendarExtender
Using the Ajax toolkit Calendar Extender in the html markup:
Above you will see that the Calendar only allows one to choose between today or tomorrow by setting
and
This can also be done in the backend using
CalendarExtender1.StartDate = DateTime.Now;
orCalendarExtender1.EndDate = DateTime.Now.AddDays(1);
One Option is to use a rangevalidator on the textbox the calenderextender is bound to. Ie if you have the TargetID of the calendar extender set to tb1 add a rangeValidator to flag when the contents of tb1 is before today.
Another option is using javascript and here is a good example: http://www.dotnetcurry.com/ShowArticle.aspx?ID=149 TIP 6.
Here is my full solution to the calendar date restriction problem: What I like about this solution is that you set the MinimumValue and MaximumValue of a RangeValidator and you do not have to modify any javascript. I never found a full solution that did not require recompiling the AjaxControlToolkit.dll. Thanks to http://www.karpach.com/ajaxtoolkit-calendar-extender-tweaks.htm for giving me the idea of how to override key methods in the calendar.js file without having to recompile the AjaxControlToolkit.dll. Also, I got "AjaxControlToolkit is undefined" javascript errors, so I changed those to Sys.Extended.UI. and it works for me when using the 4.0 version of the toolkit.
Either in Page_Load or Init or wherever, set the min and max values for your range validator:
Add this javascript somewhere in your page:
Add this text box to your asp.net page with CalendarExtenter and RangeValidator:
Just add an attribute StartDate="<%# DateTime.Now %>" in you ajaxtoolkit calendarextender control