Javascript with datepicker

3 posts, 0 answers
  1. Thibault
    Thibault avatar
    2 posts
    Member since:
    Mar 2016

    Posted 23 Mar Link to this post

    Hi all


    I will try to explain you my problem (I'm french with bad engl

    I have a datepicker wich, when date is selected, update other items (like button text...) So, I use OnSelectedDateChanged="RadDatePicker1_SelectedDateChanged"


    In the js code I need to do 2 things : 

    1 - Check the css class for make an alert or not. Because, I have day-render function wich change css class of cell if the date is on a list like that : 

     protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
                for (int i = 0; i < ListeDate.Count; i++)
                    string DateACompare = String.Format("{0:dd/MM/yyyy}", ListeDate[i]);
                    DateTime rdvDate = DateTime.ParseExact(DateACompare, "dd/MM/yyyy", null);
                    if (e.Day.Date == rdvDate)
                        //e.Cell.BackColor = Color.Red;
                        e.Cell.CssClass = "CasePrise";


    If css class is not "CasePrise" I want make and alert


    2 - Refresh my page for update other control with the date selected


    So I do that, in js :

    function RadDatePicker1_OnDateSelected(sender,args)
       //Add JavaScript handler code here
       __doPostBack('', '');
       if ($(sender).hasClass("CasePrise"))
                alert('Aucunes captures à la date selectionnée')

    function __doPostBack(eventTarget, eventArgument) {
       if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
           theForm.__EVENTTARGET.value = eventTarget;
           theForm.__EVENTARGUMENT.value = eventArgument;



    I have two problems : The first is that it don't check the cssclass

    The second is that, when it do the postback, my day_render function don't work, so, the cell in my datepicker don't have different background color as it should


    I hope my message will be understanding


    Thanks for help

  2. Thibault
    Thibault avatar
    2 posts
    Member since:
    Mar 2016

    Posted 24 Mar Link to this post



    I just need to force dayrender in my javascript function (or with another way) now

  3. DevCraft R3 2016 release webinar banner
  4. Eyup
    Eyup avatar
    2942 posts

    Posted 28 Mar Link to this post

    Hi Thibault,

    Could you summarize what you want to achieve initially with your RadDatePicker? Then we can figure out your exact requirement and suggest accurate and proper approach.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top