RadCalendar Select Week With button

2 posts, 0 answers
  1. Hyde
    Hyde avatar
    5 posts
    Member since:
    Apr 2014

    Posted 24 Apr 2014 Link to this post

    Need selected a one week with a button
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Apr 2014 in reply to Hyde Link to this post

    Hi Hyde,

    I am not clear about your requirement, please have a look into the sample code snippet which will select the current date week on button OnClick event.

    ASPX:
    <telerik:RadCalendar ID="radcalSelectWeek" runat="server">
    </telerik:RadCalendar>
    <telerik:RadButton ID="radbtnSelectWeek" runat="server" Text="SelectWeek" OnClick="radbtnSelectWeek_Click">
    </telerik:RadButton>

    C#:
    protected void radbtnSelectWeek_Click(object sender, EventArgs e)
    {
        DateTime todayDate = DateTime.Today;
        int i,j;
        CultureInfo ciCurr = CultureInfo.CurrentCulture;
        int weekNum = ciCurr.Calendar.GetWeekOfYear(todayDate, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Saturday);
        for (i=0;i<7;i++)
        {
            int tempWeek = ciCurr.Calendar.GetWeekOfYear(todayDate.AddDays(i), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Saturday);
            if (tempWeek != weekNum)
            {
                break;
            }
        }
        i++;
        radcalSelectWeek.RangeSelectionStartDate = todayDate.AddDays(-(7 - i));
        radcalSelectWeek.RangeSelectionEndDate = todayDate.AddDays(i-1);
    }

    Please elaborate your requirement if it doesn't help.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top