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

ClientEvents-OnDateClick get background color on the date clicked

1 Answer 181 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Martin asked on 11 Feb 2009, 12:51 PM
I have a small web project where im using a radcalendar.

The calendar is used to show different states shown as with different background colors. In the codebehind DayRender event i set up the Background color setting the Cell CssClass for each day...

now its possible for the user to change the state on a date by clicking it. Here is the question. ? If a date has a specific color "lets say green" and the user clicks it i want to show a confirm messagebox. How do i get the clicked dates backgroundcolor in the ClientEvent.

my aspx looks like below:


<telerik:RadCalendar ID="uiCalendarPersonal" runat="server" AutoPostBack="True" width="170px"  

The javascript for OnDateClick will look something like this

function OnDateClick(calendarInstance, args) { 
   //set set_Cancel(true) to cancel AutoPostBackOnDayClick - if any;
    // here i would like to check for the clicked dates backgroundcolor
"OnDateClick: " + args.get_renderDay().get_date(), "Postback?")); 

function TraceEvent(eventName, confirmMessage) { 
   var now = new Date(); 
   var str = "[" + now.toLocaleTimeString() + "]&nbsp;" + eventName; 
   var retValue; 
   if (confirmMessage) { 
       retValue = confirm(eventName +
":\n" + confirmMessage); 
       str += (retValue ?
"" : "&nbsp;-&nbsp;canceled"); 
   if (retValue != null
       return retValue;








1 Answer, 1 is accepted

Sort by
Telerik team
answered on 16 Feb 2009, 03:49 PM
Hello Martin,

Sample approach is shown below:
<script type="text/javascript" language="javascript"
    function getStyle(x, styleProp) 
        if (x.currentStyle) 
            var y = x.currentStyle[styleProp]; 
        else if (window.getComputedStyle) 
            var y = document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp); 
        return y; 
    function OnDateClick(sender, args) 
        alert(getStyle(args.get_domEvent().target.parentNode, "backgroundColor")); 

the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question