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

Javascript with datepicker

2 Answers 115 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Thibault
Top achievements
Rank 1
Thibault asked on 23 Mar 2016, 10:13 AM

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
   //alert(sender.get_selectedDate());
   __doPostBack('', '');
   if ($(sender).hasClass("CasePrise"))
            alert('Ok');
        else
            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;
       theForm.submit();
   }
}

 

 

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 Answers, 1 is accepted

Sort by
0
Thibault
Top achievements
Rank 1
answered on 24 Mar 2016, 10:18 AM

Up

 

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

0
Eyup
Telerik team
answered on 28 Mar 2016, 10:45 AM
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.

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
DatePicker
Asked by
Thibault
Top achievements
Rank 1
Answers by
Thibault
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or