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

Individual day style problem

9 Answers 145 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 16 Oct 2007, 02:12 PM
Hi,

I'm attempting to simply set the background color of individual days in the calendar control and am trying the following sort of thing;

        protected void DateSelect_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)  
        {  
                if(e.Day.Date == DateTime.Now.Date)  
                        e.Day.ItemStyle.CssClass = "day-error";  
        } 

Yet even though the CssClass= line gets executed it doesnt appear to have any effect in the control itself - has anyone got a working example of this being used?

Thanks

Rob

9 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 16 Oct 2007, 03:10 PM
Hi Rob,

You cannot set properties to the CalendarDay passed as a parameter. Instead we would suggest you the following approach:

protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
    if (e.Day.Date == DateTime.Today) 
    { 
        e.Cell.CssClass = "day-error"
    } 


Hope this helps.


Sincerely yours,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rob
Top achievements
Rank 1
answered on 16 Oct 2007, 03:38 PM
Thanks for that.. problem with that method seems to be that as soon as you hover over a date it loses the style as the control is not aware of the change - is there a way around this?
0
Giuseppe
Telerik team
answered on 17 Oct 2007, 11:13 AM
Hello Rob,

We are unable to reproduce the described behavior -- in our local tests once the mouse moves out of the cell it restores the custom background color. However, if you are referring to the hover style itself -- it is the same for all calendar days and cannot be changed per single day.


All the best,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
f
Top achievements
Rank 1
answered on 12 Feb 2008, 06:46 PM
Hi Manuel,

I tried your project but if you change the Skin for calendar then the "custom" css is not applied on day.
There is a workaround for this?

Thanks,
Florin
0
Giuseppe
Telerik team
answered on 13 Feb 2008, 02:11 PM
Hello florin,

For some of the skins the CssClass should look like this in order to be applied properly:

.custom a 
    background-color: red !important

Hope this helps.


Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
f
Top achievements
Rank 1
answered on 17 Feb 2008, 01:00 PM
Hi Manuel,

It worked in this way, partially.

If I set radcalendar.autopostback = true then if a choose another day ,
on custom day MouseOver the red color dissapear.
So the . custom a css style is not aplied anymore until I refresh the whole page (by pressing F5).
What do you think?

Thanks,
Florin
0
Giuseppe
Telerik team
answered on 18 Feb 2008, 12:15 PM
Hi florin,

When you mouse-over a particular calendar cell its appearance is changed according to the rules specified by the radCalHover_[SkinName] CssClass specified in the control skin and the settings you specify in the RadCalendar.DayOverStyle property. The hover style is applied to all calendar cells and cannot be customized per cell.


All the best,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
f
Top achievements
Rank 1
answered on 18 Feb 2008, 01:39 PM
Hi Manuel,

You're right,
But what I wanted to say is:
 
- I have a custom day (with custom css)
- another day is selected(causing postback)
- MouseOver on custom day
- MouseOver on another day
-  the background of the custom day is not changed in  in red. It remain in normal day style.

It is turned again in red after full page refresh.


Thanks,
Florin
0
Giuseppe
Telerik team
answered on 18 Feb 2008, 04:03 PM
Hello florin,

Unfortunately we cannot reproduce the described behavior -- could you review the attached modified sample and let us know how we can observe the problem?


Best wishes,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Calendar
Asked by
Rob
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Rob
Top achievements
Rank 1
f
Top achievements
Rank 1
Share this question
or