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

Biweekly?

1 Answer 55 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
bradley baker
Top achievements
Rank 1
bradley baker asked on 17 Sep 2009, 10:18 PM
Im looking to mark biweekly dates on a cal to show pay days.  This code works but it only shows on the current calendar how do I modify it so if the scroll thru the mutiple months those days show up as marked?


   Private Sub Page_Load(ByVal sender As ObjectByVal e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles RadCalendar1.DayRender  
        startDate = CType(RadCalendar1.CalendarView, MonthView).MonthStartDate  
        endDate = CType(RadCalendar1.CalendarView, MonthView).MonthEndDate  
        Dim _Date As Date = "2009-09-11" 
 
        Do While _Date <= Now.AddYears(1)  
            DayOfMonth = _Date.Day  
            MonthMonth = _Date.Month  
            YearYear = _Date.Year  
 
            Dim CurrentDate As DateTime = e.Day.Date 
            If startDate <= CurrentDate And CurrentDate <= endDate Then 
                If CurrentDate.Day = DayOfMonth And CurrentDate.Month = MonthMonth And CurrentDate.Year Then 
                    Dim currentCell As TableCell = e.Cell  
                    currentCell.Style("background-color") = "green" 
                End If 
            End If 
            _Date = _Date.AddDays(14)  
        Loop 
    End Sub 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 18 Sep 2009, 11:45 AM
Hi Bradley,

The server-side DayRender event handler is used to modify the initial RadCalendar monthview matrix, because it is rendered on the server. Normally, when you navigate through months client-side, the new view matrices are created and rendered on the client. So in order to display custom background color for days from other months, you need to:

1) use the client-side DayRender handler

http://www.telerik.com/help/aspnet-ajax/calendar_clientsideondayrender.html

http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/customdaycellrendering/defaultcs.aspx


or

2) set AutoPostBack="true" to RadCalendar (and ajaxify the control), so that every monthview matrix is rendered server-side.


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Calendar
Asked by
bradley baker
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or