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

RadCalendar Select Week With button

1 Answer 19 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Hyde
Top achievements
Rank 1
Hyde asked on 25 Apr 2014, 12:10 AM
Need selected a one week with a button

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 25 Apr 2014, 10:02 AM
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.
Tags
Calendar
Asked by
Hyde
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or