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

Day Cell Allignment

1 Answer 61 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Faiq
Top achievements
Rank 1
Faiq asked on 05 Jun 2009, 01:41 PM
Hi All,
I have an issue using RadCalendar.dayrender event and want to add some control into the cell based on some condition.Every thing works fine. I want the content inside the cell to left alligned. but i am unable to do it. Here is my code.

 


 

 

protected void ProcessDayEvent(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)

 

{

 

if (Session["MonthlyBooking"] != null)

 

{

 

DataTable DtMonthlyBooking = (DataTable)Session["MonthlyBooking"];

 

 

DateTime CurrentDate = e.Day.Date;

 

 

DataRow[] r = DtMonthlyBooking.Select("Date='" + CurrentDate + "'");

 

 

if (r.Length > 0)

 

{

 

TimeSpan ts = Convert.ToDateTime(r[0]["startTime"].ToString()).TimeOfDay;

 

 

int shour = ts.Hours;

 

 

int sm = ts.Minutes;

 

ts =

Convert.ToDateTime(r[0]["EndTime"].ToString()).TimeOfDay;

 

 

int Ehour = ts.Hours;

 

 

int Em = ts.Minutes;

 

 

 

 

 

e.Cell.Text = shour.ToString() +

":" + sm.ToString() + "-" + Ehour.ToString() + ":" + Em.ToString() ;
e.Cell.HorizontalAlign = HorizontalAlign.Left;
}
}
}

I have also tried to assign some Css class as 
e.Cell.Text = shour.ToString() + ":" + sm.ToString() + "-" + Ehour.ToString() + ":" + Em.ToString() ;

 

e.Cell.CssClass="selected"

and

 

 

.selected

 

 

 

 

 

{

 

background-color: #B5CCEA;

 

 

text-align: left;

 

 

padding-left: 0px;

 

 

margin-left: 0;

 

 

height: 10px;

 

}

in aspx page.



but it is also not working.Plz help me out.
Thanks in Advance.

 

 


1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 08 Jun 2009, 10:17 AM
Hi Faiq,

The HorizontalAlign property is rendered as an align HTML attribute, which is now obsolete and is easily overridden by CSS styles.

So it is better to use :

e.Cell.Attributes.Add("style", "text-align:left");

If you prefer to use a custom CSS class, you have to make sure that your CSS rule has a higher specificity than the corresponding skin CSS rule, which has to be overridden, e.g.:


.RadCalendar_SkinName  .rcRow  .selected
{
       text-align: left ;
}


All the best,
Dimo
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.
Tags
Calendar
Asked by
Faiq
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or