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

How to set ItemStyle properties for Special Day programmatically?

8 Answers 281 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
hkdave95
Top achievements
Rank 2
hkdave95 asked on 06 Oct 2009, 06:51 AM
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

8 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 08 Oct 2009, 10:48 AM
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.
0
hkdave95
Top achievements
Rank 2
answered on 08 Oct 2009, 07:06 PM
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

0
Shinu
Top achievements
Rank 2
answered on 09 Oct 2009, 06:32 AM
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.
0
hkdave95
Top achievements
Rank 2
answered on 09 Oct 2009, 07:37 AM
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
0
Nikolay Rusev
Telerik team
answered on 14 Oct 2009, 10:08 AM
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.
0
Lohith
Top achievements
Rank 1
answered on 20 Nov 2012, 06:19 AM

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

0
Eyup
Telerik team
answered on 22 Nov 2012, 02:33 PM
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.
0
Princy
Top achievements
Rank 2
answered on 23 Jul 2013, 10:51 AM
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.
Tags
Calendar
Asked by
hkdave95
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
hkdave95
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Lohith
Top achievements
Rank 1
Eyup
Telerik team
Princy
Top achievements
Rank 2
Share this question
or