Individual day style problem

10 posts, 0 answers
  1. Rob
    Rob avatar
    2 posts
    Member since:
    Oct 2007

    Posted 16 Oct 2007 Link to this post

    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
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 16 Oct 2007 Link to this post

    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
  3. Rob
    Rob avatar
    2 posts
    Member since:
    Oct 2007

    Posted 16 Oct 2007 Link to this post

    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?
  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 17 Oct 2007 Link to this post

    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
  5. f
    f avatar
    12 posts
    Member since:
    Nov 2007

    Posted 12 Feb 2008 Link to this post

    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
  6. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 13 Feb 2008 Link to this post

    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
  7. f
    f avatar
    12 posts
    Member since:
    Nov 2007

    Posted 17 Feb 2008 Link to this post

    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
  8. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 18 Feb 2008 Link to this post

    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
  9. f
    f avatar
    12 posts
    Member since:
    Nov 2007

    Posted 18 Feb 2008 Link to this post

    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
  10. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 18 Feb 2008 Link to this post

    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
Back to Top