I've just been asked to find a solution to stop users choosing dates in the past in a calendarextender control. After using a little google-phoo, I found a couple of solutions which involved extending the extender itself. Altering the calendar.js then recompiling it and putting it back into your solution. That just seems a bit excessive to me. So I got to thinking couldn't I just use some in page JavaScript to trap the date entered.
First we add a text box and a calendarextender:
|
you may notice that the CalendarExtender has an event attached (checkDate) - this is the JavaScript function you want it to call when ever you select a new date, add this function the top of your aspx page:
if(selectedDate < todayDate) |
Simple and the nice thing is it's reusable for all the calendarextenders on your page, just add the checkDate function to your other extenders.
Happy Coding
2 comments:
Thanks a lot u really helped me...
Post a Comment