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

Set the starting week to current week

1 Answer 112 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Leng Xiong
Top achievements
Rank 1
Leng Xiong asked on 17 Nov 2009, 10:13 PM
Is there a way using the RadCalendar or setting the Calendar for the RadDatePicker to set the first week that appears in the calendar pop-up to the current week. For example, like today, the date is November 17th. I want the calendar to start from Sunday the 15th and display half of December, instead of displaying the whole entire month of November. I am not concerned with the days of this month that have already passed, but I don't want to just disable those days, I don't even want to show them. Is this possible?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Nov 2009, 06:58 AM
Hi Leng Xiong,

I tried following code in order to achieve the scenario. Give a try with this and see whether it helps.

aspx:
 
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" OnPreRender="RadDatePicker1_PreRender"
        <Calendar ShowRowHeaders="False" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
        </Calendar> 
        <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy"
        </DateInput> 
    </telerik:RadDatePicker> 

cs:
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        RadDatePicker1.Calendar.DayRender += new Telerik.Web.UI.Calendar.DayRenderEventHandler(Calendar_DayRender); 
    } 
    void Calendar_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
    { 
        if (e.Day.Date < DateTime.Now.Date) 
        { 
            e.Cell.Style.Add("display""none"); 
        } 
    } 
    protected void RadDatePicker1_PreRender(object sender, EventArgs e) 
    { 
        RadDatePicker1.Calendar.FirstDayOfWeek = (System.Web.UI.WebControls.FirstDayOfWeek) DateTime.Now.DayOfWeek; 
    } 

Regards,
Shinu.
Tags
Calendar
Asked by
Leng Xiong
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or