Welcome Guest Search | Active Topics | Sign In | Register

Calendar2.DisabledDates.Remove(2007 - 7 - 4) Options
Gary
Posted: Friday, July 6, 2007 11:04:27 AM
Rank: Newbie
Groups: Member

Joined: 7/6/2007
Posts: 1
howdy, I'm evaluating your calendar object. What I would like to do in my application is set a range of dates to disabled, and then when my form loads I need to "enable" certain dates based on my database values. Is the Calendar2.DisabledDates.Remove the correct method? If yes, can you show me the proper syntax.

Thanks
eo_support
Posted: Friday, July 6, 2007 9:22:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
hi, Gary

Yes, this is the one that you need.
It is very easy to use it. Here is a little example:
Put a datepicker/calendar in your page, and put a button in your page as well.
Code: C#
public static DateTime dtToday = new DateTime(2007, 7, 6);
    protected void Page_Load(object sender, EventArgs e)
    {
        this.DatePicker1.DisabledDates.Add(dtToday);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.DatePicker1.DisabledDates.Remove(dtToday);
    }

When the page gets load, you can see the date 07/06 is disabled. But after you click Button1, it becomes enabled. The only thing you need be careful is, even in most case, it only uses Date part of DateTime in UI, but when you call Add or Remove, comes to compare, it compares the whole DateTime object, including date and time. Both has to be the same, otherwise, it wil show IndexOutofRange or some similar error.

Thanks.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.