This is a migrated thread and some comments may be shown as answers.
set new Date on Previous Selection Date
7 Answers 48 Views
This is a migrated thread and some comments may be shown as answers.
waseem
Top achievements
Rank 2
waseem asked on 01 Feb 2010, 04:12 PM

Dear,

always i m getting error when i work on Client side Datetimepicker.

very simple criteria. datetpicker1 date become the selected and minimumdate of datepicker2.

WIn7 VS2010 IE8 and telerik 2009 Version Q2 2009 released 08/26/2009
ERROR:

Message: Object doesn't support this property or method
Line: 72
Char: 13
Code: 0
URI: http://localhost:49204/WebSite1/ 

var DateFrom;
var DateTo;
var RDP1;
var RDP2;
 

function pageLoad() {

        

            myLabel = document.getElementById("lblNts");

            RDP1 = document.getElementById("RadDatePicker1");
            RDP2 = document.getElementById("RadDatePicker2");

        }
 

function DateSelected(sender, e) {
 
           var minDate = new Date();
            var nMonth;
           
            DateFrom = e.get_newDate().toDateString();
           
            var myFDate = DateFrom.split(" ");
           
           
            if (myFDate[1] == 'Jan') {
                nMonth = '01';
            } else if (myFDate[1] == 'Feb') {
                nMonth = '02';
            } else if (myFDate[1] == 'Mar') {
                nMonth = '03';
            } else if (myFDate[1] == 'Apr') {
                nMonth = '04';
            } else if (myFDate[1] == 'May') {
                nMonth = '05';
            } else if (myFDate[1] == 'Jun') {
                nMonth = '06';
            } else if (myFDate[1] == 'Jul') {
                nMonth = '07';
            } else if (myFDate[1] == 'Aug') {
                nMonth = '08';
            } else if (myFDate[1] == 'Sep') {
                nMonth = '09';
            } else if (myFDate[1] == 'Oct') {
                nMonth = '10';
            } else if (myFDate[1] == 'Nov') {
                nMonth = '11';
            } else if (myFDate[1] == 'Dec') {
                nMonth = '12';
            } else {
                nMonth = 'NA';
            }

            minDate.setFullYear(myFDate[3], nMonth - 1, myFDate[2]);

            RDP2.set_selectedDate(minDate);

}

 
<telerik:RadDatePicker ID="RadDatePicker1" Runat="server" MinDate="<%#DateTime.Now %>">
<ClientEvents OnDateSelected="DateSelected" />
<DateInput DateFormat="dd-MM-yyyy"></DateInput>
</telerik:RadDatePicker>

 

7 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 02 Feb 2010, 07:19 AM
Hi Muhammad,

In order to use the client-side API of the RadDatePicker you need to access its client-side object via the $find() method shortcut:
RDP1 = $find("RadDatePicker1");
RDP2 = $find("RadDatePicker2");
You can read more about this in the following help article:

http://www.telerik.com/help/aspnet-ajax/calendar_clientsidebasics.html

Greetings,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
waseem
Top achievements
Rank 2
answered on 03 Feb 2010, 07:47 AM

Thank you Mr.Pavel,

i m replying may be somebody fighting to do this small thing....

 function DateSelected(sender, e) {

             var RDP1 = $find("RadDatePicker1");
             var RDP2 = $find("RadDatePicker2");

             var myDate1 = e.get_newDate().toDateString();

             var minDate = new Date();
             var myFDate = myDate1.split(" ");

             if (myFDate[1] == 'Jan') {
                 nMonth = '01';
             } else if (myFDate[1] == 'Feb') {
                 nMonth = '02';
             } else if (myFDate[1] == 'Mar') {
                 nMonth = '03';
             } else if (myFDate[1] == 'Apr') {
                 nMonth = '04';
             } else if (myFDate[1] == 'May') {
                 nMonth = '05';
             } else if (myFDate[1] == 'Jun') {
                 nMonth = '06';
             } else if (myFDate[1] == 'Jul') {
                 nMonth = '07';
             } else if (myFDate[1] == 'Aug') {
                 nMonth = '08';
             } else if (myFDate[1] == 'Sep') {
                 nMonth = '09';
             } else if (myFDate[1] == 'Oct') {
                 nMonth = '10';
             } else if (myFDate[1] == 'Nov') {
                 nMonth = '11';

             } else if (myFDate[1] == 'Dec') {
                 nMonth = '12';
             } else {
                 nMonth = 'NA';
             }

             minDate.setFullYear(myFDate[3], nMonth-1, myFDate[2]);

             RDP2.set_minDate(minDate);
             RDP2.set_selectedDate(minDate);



OR


             var date = RDP1.get_selectedDate();

             date.setDate(date.getDate() + 1);
            
             RDP2.set_minDate(date);
             RDP2.set_selectedDate(date);



}



0
waseem
Top achievements
Rank 2
answered on 03 Feb 2010, 10:12 AM
Dear pavel,

what if we use UserControl. becuase i am intresetd to use UserControl but this code is not working...

"null" error message is coming.

0
Pavel
Telerik team
answered on 04 Feb 2010, 02:45 PM
Hi Muhammad,

In this case the ClientID of the DatePicker differs from the ID you set on the server because they are in a different naming container (the user control). I can recommend you the following blog post which elaborates on this topic:
http://blogs.telerik.com/atanaskorchev/posts/08-06-06/the_difference_between_id_clientid_and_uniqueid.aspx

In order to make it work you need to get the client id of the RadDatePickers as shown in the help article referenced previously:
var RDP1 = $find("<%= RadDatePicker1.ClientID %>");
var RDP2 = $find("<%= RadDatePicker2.ClientID %>");


Kind regards,
Pavel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
waseem
Top achievements
Rank 2
answered on 06 Feb 2010, 05:45 PM
Dear,

Thanks you give me a great information. that concept will solves my lots of problem.

but when i am using Telerik AJAX control. its gives me error.

first of all I can't use Equal Sign there. $find("<%=controlName.ClientID"); it return error and if you replace with "#" its fine.
but Error will come with this code $find("<%#controlName.ClientID"); null exception Error unable to find the control.

any suggestion.
0
Accepted
Pavel
Telerik team
answered on 08 Feb 2010, 03:04 PM
Hi Muhammad,

I am attaching for you a simple sample which is using the script you have provided. Try it out and let us know if it helps.

All the best,
Pavel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
waseem
Top achievements
Rank 2
answered on 09 Feb 2010, 05:51 AM
:) Thank you so much for your great effort highly appericated. its work.
I am posting a new thread on Radrotator if you have a time to check out.
Asked by
waseem
Top achievements
Rank 2
Answers by
Pavel
Telerik team
waseem
Top achievements
Rank 2
Share this question
or