How to set ItemStyle properties for Special Day programmatically?

9 posts, 0 answers
  1. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 06 Oct 2009 Link to this post

    Hi

    ItemStyle property is ReadOnly on SpecialDay!

    How can I set it's property?

    My Code ...

    loCurrentSpecialDays[lnCount] = new Telerik.Web.UI.RadCalendarDay()  
                        {  
                            Date = loAppointment.APPDStart.AddDays(lnCount),  
                            IsDisabled = true,  
                            IsSelectable = false,  
                            ToolTip = ((FLMVilla.App_Code.Enums.ScheduleTypes)loAppointment.APPNScheduleType).ToString().Replace("_", " ")  
                        }; 

    I would like to add an extra line to set the ItemStyle like "ItemStyle = new System.Web.UI.WebControls.TableItemStyle()". But compiler says Readonly!

    Kind Regards

    David
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 08 Oct 2009 Link to this post

    Hello David,

    You can use CopyFrom method of Style class:

    RadCalendarDay day = new RadCalendarDay
    {
       Date = DateTime.Today
    };
    TableItemStyle style = new TableItemStyle();
    style.BackColor = Color.Red;
    day.ItemStyle.CopyFrom(style);


    Sincerely yours,
    Nikolay
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 08 Oct 2009 Link to this post

    Hi

    Thank you for your reply.

    However, my attempts at making the Spcial Days Forecolor to be Red are not working.

    How do I make a Special Day stand out on the Calendar?

    Kind Regards

    David

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Oct 2009 Link to this post

    Hello David,

    Have you tried applying CSS in order to set the ForeColor for SpecialDays as shown below?

    C#:
     
    day.ItemStyle.CssClass = "MyClass";  

    CSS:
      
    <style type="text/css">  
    .MyClass a  
    {  
        color: Red!important; 
    }  
    </style>  

    -Shinu.
  6. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 09 Oct 2009 Link to this post

    Hi

    Yes I have.

    Also I have tried setting the CssClass on the DisabledDay property of the Calendar. Since my SpecialDays are all disabled i thought this would have an effect.

    Any more ideas?

    Kind Regards

    David
  7. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 14 Oct 2009 Link to this post

    Hi David,

    Following code should work for you:
    1.<telerik:RadCalendar runat="server" ID="RadCalendar1">
    2.        <SpecialDays>
    3.            <telerik:RadCalendarDay Date="2009/10/14" 
    4.                IsSelectable="false" IsDisabled="true">
    5.            </telerik:RadCalendarDay>
    6.        </SpecialDays>
    7.    </telerik:RadCalendar>

    1.<style type="text/css">        
    2.        .rcMain .rcRow td.rcDisabled a
    3.        {
    4.            color:Red;
    5.            }
    6.    </style>


    Regards,
    Nikolay
    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.
  8. Lohith
    Lohith avatar
    7 posts
    Member since:
    Oct 2012

    Posted 20 Nov 2012 Link to this post

    Hi,

    I do as you suggest, that is specify the CssClass.  I have also "!important" in my CSS for every property set.
    e.Day.ItemStyle.CssClass = "MyClass"; 

    Also for your information I am writing this piece of code in DayRender event.  Seems like it is not being applied.
    Is it the right place for setting the CSSClass or Should I tap into anyother event in the control lifecycle.  If you have a code sample please share will really appreciate.

    You also suggest using the below in CSS this works but i need to change CSS dynamically and hence need this functionality.
    .rcMain .rcRow td.rcDisabled a

    Thanks in advance.
    Lohitha

  9. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 22 Nov 2012 Link to this post

    Hello ,

    Please try the following approach:
    <style type="text/css">
        .MyClass a
        {
            color: Red !important;
        }
    </style>
    C#:
    protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
    {
        e.Cell.CssClass = "MyClass";
    }

    I hope this will prove helpful. Please give it a try and let me know about the result.

    Kind regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  10. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Jul 2013 Link to this post

    Hi Lohith,

    You can try the following C# code in the DayRender event to set the ForeColor of the RadCalendar Days dynamically.

    C#:
    protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
    {
        // clear the default cell content (anchor tag) as we need to disable the css effect for this cell
        e.Cell.Text = "";
        //adding a new label as the calendar day in order to apply the required styles
        Label label = new Label();
        label.Text = e.Day.Date.Day.ToString();
        label.ForeColor = System.Drawing.Color.Red;
        e.Cell.Controls.Add(label);
    }

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017