set new Date on Previous Selection Date

8 posts, 1 answers
  1. waseem
    waseem avatar
    32 posts
    Member since:
    Jun 2006

    Posted 01 Feb 2010 Link to this post

    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>

     

  2. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 02 Feb 2010 Link to this post

    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.
  3. waseem
    waseem avatar
    32 posts
    Member since:
    Jun 2006

    Posted 03 Feb 2010 Link to this post

    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);



    }



  4. waseem
    waseem avatar
    32 posts
    Member since:
    Jun 2006

    Posted 03 Feb 2010 Link to this post

    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.

  5. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 04 Feb 2010 Link to this post

    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.
  6. waseem
    waseem avatar
    32 posts
    Member since:
    Jun 2006

    Posted 06 Feb 2010 Link to this post

    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.
  7. Answer
    Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 08 Feb 2010 Link to this post

    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.
  8. waseem
    waseem avatar
    32 posts
    Member since:
    Jun 2006

    Posted 08 Feb 2010 Link to this post

    :) 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.
Back to Top