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

higlighting current week in the calendar on pageload

1 Answer 29 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Regeesh Joseph
Top achievements
Rank 1
Regeesh Joseph asked on 23 Jul 2010, 02:44 PM
Hai,

I want to get the current week to be highlighted on the radcalendar. How to get it done?

Plz help me.

Thanks & regards,
Regeesh Joseph

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Jul 2010, 07:21 AM
Hello Rageesh,

The following code snippet will be useful for you to achieve this.

ASPX:
<telerik:RadCalendar ID="RadCalendar2" runat="server" OnDayRender="RadCalendar2_DayRender">
</telerik:RadCalendar>

C#:
int weekNumber;
   protected void Page_Load(object sender, EventArgs e)
   {
       weekNumber = GetNumber(DateTime.Now.Date);
   }
 protected void RadCalendar2_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
   {
       if (GetNumber(e.Day.Date) == weekNumber)
       {
           e.Cell.Style.Add("background-color", "Aqua");
       }
   }
   public static int GetNumber(DateTime dtDate)
   {
       System.Globalization.CultureInfo ciGetNumber = System.Globalization.CultureInfo.CurrentCulture;
       int returnNumber = ciGetNumber.Calendar.GetWeekOfYear(dtDate, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
       return returnNumber;
   }

Thanks,
Princy.
Tags
Calendar
Asked by
Regeesh Joseph
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or