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

How to make the month display for an old date?

2 Answers 70 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
DaveBarkshire
Top achievements
Rank 1
DaveBarkshire asked on 05 Jul 2012, 02:23 PM
I have got a calendar working but when I set the date to an old date (server side) the calendar displays the current month.

I am showing three months in a row. The date assignment during the page onload is working properly.

    tclCalendar.SelectedDate = dteDate;

    tclCalendar.DataBind();


Ideally the middle month should be the month of the date which I have set.
Is there somthing else which needs setting?

Also, how do I remove the week number column?

 

<telerik:RadCalendar ID="tclCalendar" runat="server" DayNameFormat="Short"

 

 

Skin="Web20" EnableMultiSelect="False" UseRowHeadersAsSelectors="True" UseColumnHeadersAsSelectors="True"

 

 

MultiViewColumns="3" AutoPostBack="True" EnableNavigationAnimation="True"

 

 

CultureInfo="English (United Kingdom)" ShowOtherMonthsDays="False" TitleStyle-ForeColor="White"

 

 

TitleStyle-CssClass="smallButton" WeekendDayStyle-BackColor="#F7F7F0" DayOverStyle-BorderColor="Black"

 

 

EnableViewSelector="True">

 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2012, 12:31 PM
Hi DaveBarkshire,

Here is the code that I tried for showing three months in a row and to set the selected month as the middle month. Please try setting ShowRowHeaders property of RadCalendar to false to remove the week number column.

ASPX:
<telerik:RadCalendar ID="tclCalendar" runat="server" DayNameFormat="Short" Skin="Web20" ShowRowHeaders="false" EnableMultiSelect="False" UseRowHeadersAsSelectors="True" UseColumnHeadersAsSelectors="True"  MultiViewColumns="3" AutoPostBack="True" EnableNavigationAnimation="True" CultureInfo="English (United Kingdom)" ShowOtherMonthsDays="False" TitleStyle-ForeColor="White" TitleStyle-CssClass="smallButton" WeekendDayStyle-BackColor="#F7F7F0" DayOverStyle-BorderColor="Black" EnableViewSelector="True">
</telerik:RadCalendar>

C#:
protected void Page_Load(object sender, EventArgs e)
   {
        DateTime dteDate = new DateTime(2010, 1, 18);
        tclCalendar.SelectedDate = dteDate;
        if (tclCalendar.SelectedDate.Month != 1)
        {
            int m = tclCalendar.SelectedDate.Month - 1;
            tclCalendar.FocusedDate = new DateTime(tclCalendar.SelectedDate.Year, m, tclCalendar.SelectedDate.Day);
        }
        else
        {
            int m = 12;
            int y = tclCalendar.SelectedDate.Year - 1;
            tclCalendar.FocusedDate = new DateTime(y, m, tclCalendar.SelectedDate.Day);
        }
        tclCalendar.DataBind();
  }

Hope this helps.

Thanks,
Princy.
0
DaveBarkshire
Top achievements
Rank 1
answered on 06 Jul 2012, 02:28 PM
Many thanks Princy. That was very useful.
Tags
Calendar
Asked by
DaveBarkshire
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
DaveBarkshire
Top achievements
Rank 1
Share this question
or