Basically, I just want allow select dates greater than today. I’d prefer this way to avoid show alert messages.
Basically, I just want allow select dates greater than today. I’d prefer this way
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think that it is supported in the current version of the Toolkit to restrict selectable dates. This is a simple workaround handling the
ClientDateSelectedChanged-Event and validate the selected date:There could be instances where you do not want the user to select a day earlier than the current date. For example: when you are providing the user a form to book tickets, you would not like him to choose an earlier date. To achieve this requirement, use the following javascript code.
Call the code:
In the javascript, just change this line
sender._selectedDate > new Date()Note: You may argue that the user can still change the date by typing into the textbox or entering an invalid date. Well that can be easily handled using a ValidationControl and is covered in the next tip.
A simple way to add validation to the Calendar is to add a ValidationControl to the textbox associated with a CalendarExtender. You have two choices:
Extenderto theValidationControl. To do so, drag and drop aValidationControl> click on the smart tag of theValidationControl> chooseAdd Extender. From the Extender Wizard, chooseValidatorCalloutExtender. Using this approach makes it extremely easy to discover and attach control extenders to your controls. In VS 2005, you had to do this process manually, by wiring up control extenders.We will go ahead with option A. We will be adding two
ValidationControlsto theTextBox. The first, aCompareValidatorto check if the user does not enter an invalid date (Eg: May 32) and second, aRangeValidatorto keep the date range as desired.Adding CompareValidator
In the code behind of your page, add this code
C#
VB.NET
Well those were some tips associated with the
CalendarExtender. As future versions of the toolkit are released, we should be hopeful that there will exist easier ways, of achieving this functionality.From: http://www.dotnetcurry.com/ShowArticle.aspx?ID=149
Another advanced approach would be to extend the CalendarExtender javascript, but then you have your own custom version of the ajax toolkit.
http://codegoeshere.blogspot.com/2007/06/extending-calendarextender.html