Getting current month without a day selected...

4 posts, 0 answers
  1. Andrew Galea
    Andrew Galea avatar
    22 posts
    Member since:
    Nov 2009

    Posted 24 May 2010 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 May 2010 Link to this post

    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.
  3. Andrew Galea
    Andrew Galea avatar
    22 posts
    Member since:
    Nov 2009

    Posted 24 May 2010 Link to this post

    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
  4. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 27 May 2010 Link to this post

    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.
Back to Top