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

Change selected date format

5 Answers 131 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Needha
Top achievements
Rank 1
Needha asked on 19 Jul 2013, 12:20 PM
Hi

When I select date from the raddatepicker, it is displayed in mm dd yy format in the date input. So how can I change the selected date format to dd mm yyyy format?

Thankyou
Needha

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jul 2013, 12:33 PM
Hi Needha,

Try setting the DisplayDateFormat to "dd/MM/yyyy" as shown below.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    <DateInput DisplayDateFormat="dd/MM/yyyy">
    </DateInput>
</telerik:RadDatePicker>

Thanks,
Shinu.
0
Needha
Top achievements
Rank 1
answered on 23 Jul 2013, 08:27 AM
It works. Shinu I have another one requirement. I want to give red color to all sundays in the calendar of a datepicker and user should not be able to select those.
0
Shinu
Top achievements
Rank 2
answered on 23 Jul 2013, 10:38 AM
Hi Needha,

Please have a look into the following code I tried which works fine at my end.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    <Calendar runat="server" OnDayRender="RadCalendar1_DayRender">
    </Calendar>
</telerik:RadDatePicker>

C#:
protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
{
    if (e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
    {
        // 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);
 
        RadCalendarDay calendarDay = new RadCalendarDay();
        calendarDay.Date = e.Day.Date;
        calendarDay.IsSelectable = false; //disable date selection
        RadDatePicker1.Calendar.SpecialDays.Add(calendarDay);
    }
}

Thanks,
Shinu.
0
Needha
Top achievements
Rank 1
answered on 23 Jul 2013, 05:45 PM
Hi shinu

I think I didnt mention my requirement clearly. I need to set red color to the background and not as the fore color.
0
Shinu
Top achievements
Rank 2
answered on 24 Jul 2013, 04:44 AM
Hi Needha,

You can try the following C# code instead of the one I wrote to set the label fore color.

C#:
label.BackColor = System.Drawing.Color.Red;

Thanks,
Shinu.
Tags
Calendar
Asked by
Needha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Needha
Top achievements
Rank 1
Share this question
or