?
Solved

show selected dates in a asp calendar

Posted on 2007-07-20
6
Medium Priority
?
199 Views
Last Modified: 2010-04-15
Hi there,
            I am supposed to allow the user to select a date from a calendar which will be shown in a textbox. But here is a confusion, there is a dropdown which has the seasons as spring, summer, winter, fall. First the user selects the season, then they see a small image button for a calendar which they click on to see the calendar. The calendar will only show the dates visible depending upon what season they select. For example, if the user selects spring, they can only see the dates from 03/07/2008 to 07/08/2008. All the other dates could be grayed out or invisible. is it possible?
0
Comment
Question by:siddhuoops
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19532582
1) ASP.NET or WinForms?

2) 2005 or 2003?

Bob
0
 

Author Comment

by:siddhuoops
ID: 19532645
ASP .Net  2005
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19532752
The Calendar control has the DayRender event handler, where you can format the cell how you want:

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        // Hide any days that you don't want to be visible.
        if (e.Day.Date.Day == 20)
            e.Cell.ForeColor = Color.White;
    }

Bob
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:siddhuoops
ID: 19532790
so , in my case will it be sth like this

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (ddrseason.SelectedItem.Value == "Spring")
         {
            //if (e.Day.Date.Day == 20)
            //e.Cell.ForeColor = Color.White;
            what would I have to do here so as to hide all the dates except dates from 03/07/2008 to 07/08/2008?
    }
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 19533026
1) Set a start date and end date when the DropDownList is changed

2) Check the date range in the DayRender:

   private DateTime _seasonStartDate = new DateTime(DateTime.Now.Year, 1, 1);
    private DateTime _seasonEndDate = new DateTime(DateTime.Now.Year, 3, 31);
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.Date < _seasonStartDate || e.Day.Date > _seasonEndDate)
        {
            e.Cell.ForeColor = Color.Gray;
        }
    }

Bob
0
 

Author Comment

by:siddhuoops
ID: 19533445
thank you Bob!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question