+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / EventsScheduleView - Simple Events Calendar

EventsScheduleView - Simple Events Calendar

6 posts, 0 answered
  1. Eric Wallace
    Eric Wallace avatar
    66 posts
    Registered:
    08 Oct 2009
    14 Apr 2010
    Link to this post
    What I am wanting to do is to display a simple calendar for the EventsScheduleView control that would highlight the days which have an event (or events). Once clicked, it would go to a page for events for that day. it would be approx. 175x175 pixels in size, and similar in concept to the attached image file.

    Is there any way to achieve this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Apr 2010
    Link to this post
    Hi Eric Wallace,

    Please take a look at this post Event Schedule View as Calendar

    Sincerely yours,
    Ivan Dimitrov
    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.
  3. Eric Wallace
    Eric Wallace avatar
    66 posts
    Registered:
    08 Oct 2009
    15 Apr 2010
    Link to this post
    I'm close to being able to do what I'd like to do. However, I am having a problem with the radcalendar, and I have always found this control extremely frustrating to use because I cannot simply get the date that was clicked.

    I'm looping through all the events on page load, and for each event I'm adding a selected date to the rad calendar. But it seems there is no way to simply get the date that was clicked on when autopostback is set to true. Selected date is not correct. It just gets the last date that was added to the SelectedDates collection. SelectedDates[SelectedDates.Count - 1] is not correct either because if June 5th is the last one added, and I click May 8th, June 5th is returned.

    Here's my code. It's from a user control that has a radcalendar and nothing else.

    private Guid _pageId = Guid.Empty;
        private string _navigateUrl = string.Empty;
     
        /// <summary>Gets or sets ID to a SitefinityPage</summary>
        /// <value>Sitefinity Page ID.</value>
        [TypeConverter("Telerik.Cms.Web.UI.GuidTypeConverter, Telerik.Cms"),
            Category("Navigation"),
            WebEditor("Telerik.Cms.Web.UI.DhlIdEditor, Telerik.Cms"),
            DisplayName("Events Page"),
            DefaultValue(typeof(Guid), "00000000-0000-0000-0000-000000000000")]
        public Guid PageId
        {
            get
            {
                return this._pageId;
            }
            set
            {
                this._pageId = value;
            }
        }
     
        [UrlProperty, WebEditor("Telerik.Cms.Web.UI.DhlUrlEditor, Telerik.Cms"), Bindable(true), Category("Navigation"), DefaultValue("")]
        public string NavigateUrl
        {
            get
            {
                return this._navigateUrl;
            }
            set
            {
                this._navigateUrl = value;
            }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {       
            Telerik.Events.EventsManager mgr = new Telerik.Events.EventsManager("Events");
            if (!Page.IsPostBack)
            {
                foreach (IEvent evt in mgr.GetEvents())
                    calendar.SelectedDates.Add(new RadDate(evt.Start));
            }
        }
     
        protected void calendar_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
        {
            //Response.Redirect(this._navigateUrl + "?eventsdate=" + Server.UrlEncode(e.? << What goes here);
        }

    So my question is this now...if you add selected dates to a radcalendar, and a user clicks any date on the calendar, how do you get date that was clicked on a server-side postback?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Apr 2010
    Link to this post
    Hello Eric Wallace,

    You get the selected date by subscribing for SelectionChanged

    The SelectedDate property specifies the currently selected date when the calendar allows single-date selection (EnableMultiSelect="false"). When the calendar allows multiple days to be selected, the SelectedDates property specifies the initially selected dates.

    void RadCalandar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
       {
          
           DateTime[] dates =  e.SelectedDates.ToArray();
           foreach (var d in dates)
           {
               Response.Write(d.ToShortDateString());
           }
           
       }

    another sample

    protected void RadCalendar1_SelectionChanged(object sender, SelectedDatesEventArgs e)
    {
     Label1.Text = "Selected dates are:<br />";
     for (int i=0; i< e.SelectedDates.Count; i++)
     {
        Label1.Text += (e.SelectedDates[i]).Date.ToString() + ",<br />";
     }
    }

    You could use EnableMultiSelect="false.

    Greetings,
    Ivan Dimitrov
    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.
  5. Eric Wallace
    Eric Wallace avatar
    66 posts
    Registered:
    08 Oct 2009
    15 Apr 2010
    Link to this post
    Neither of those are viable, as this calendar is for events, which can have multiple selected dates. If 3 dates are set as selected, and the user clicks the middle date, how do I know it was the selected date at index 2 that was clicked?

    Edit:
    I decided to use the SpecialDays collection instead and set  the cssclass on the RadCalendarDay, and have the desired functionality. Thanks again Ivan.
  6. ashes
    ashes avatar
    1 posts
    Registered:
    22 Feb 2011
    20 Oct 2011
    Link to this post
    I want something like given in Screen shot but for ASP.NET MVC ... Where the background color of Dates will be coming from my database . How to achieve this using TELERIK MVC Calendar ?? Any Ideas ?? I have posted few questions on stackoverflow and on Telerik MVC Forums but i havent received any response yet ...
Register for webinar
6 posts, 0 answered