This is a migrated thread and some comments may be shown as answers.

Getting current month without a day selected...

3 Answers 188 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Andrew Galea
Top achievements
Rank 1
Andrew Galea asked on 24 May 2010, 09:41 AM
I am having a pretty big issue with the calendar control for my web site (http://www.rankingshq.com/public/eventcalendar.aspx).

So basically a visitor will navigate to a month and then click on the "Go" button which is meant to refresh the tournament calendar and filter by the month they have navigated to.

The issue is that the user will not select a specific day on the calendar. They only care about the month they have navigated to. So when I try to access the current month in the code behind I am unable to get the month they have navigated to, it keeps on referencing the month which has a selected day in it...I have pasted the lines of code that perform the filter below.

if (chkIncludeCalendar.Checked) 
        { 
            //DateTime selectedMonthStart = new DateTime(eventCalendar.CalendarView.ViewStartDate.Year, eventCalendar.SelectedDate.Month, 1); 
            filter.AddWithAnd(TournamentFields.StartDate >= eventCalendar.CalendarView.ViewStartDate); 
            filter.AddWithAnd(TournamentFields.StartDate <= eventCalendar.CalendarView.ViewEndDate); 
        } 

So if I want to reference the month that has been navigated to, is this possible without the user being forced to selected a specific day in that month?

Regards,
Andrew Galea

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 May 2010, 10:45 AM
Hello  Andrew Galea,

You can use the FocusedDate property to get the date which has been navigated to.

C#:
 
    DateTime dt = (DateTime)RadCalendar1.FocusedDate.Date;  
    string month = dt.ToString("MMMM");  
 

Regards,
Princy.
0
Andrew Galea
Top achievements
Rank 1
answered on 24 May 2010, 11:46 AM
Yeah I tried this but it still does not work under my situation, not sure why. If the user clicks on the button twice, then it picks up the fact they have navigated to a new month, but the first time it still references the previous month in the FocusedDate property as well.

Andrew
0
Mira
Telerik team
answered on 27 May 2010, 11:22 AM
Hello Andrew,

I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this post.

Please, take a look at it and let me know whether it helps.

All the best,
Mira
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Calendar
Asked by
Andrew Galea
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andrew Galea
Top achievements
Rank 1
Mira
Telerik team
Share this question
or