Change selected date format

6 posts, 0 answers
  1. Needha
    Needha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 19 Jul 2013 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jul 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Needha
    Needha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 23 Jul 2013 Link to this post

    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.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Jul 2013 Link to this post

    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.
  6. Needha
    Needha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 23 Jul 2013 Link to this post

    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.
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Jul 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017