How to bind a Listbox item to the datepicker

8 posts, 1 answers
  1. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 21 Dec 2010 Link to this post

    Hi,
    I'm trying to write code to change my datepicker textbox control date based on selected date in the listbox item.

    How do I bind the two together? If I click on "Today" in the listbox, I want my datepicker textbox to update to today's date.

    I have attached a image of the ascx page.

    Thank you,

    Cmc
  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 27 Dec 2010 Link to this post

    Hello Carlos,

    Please examine the attached example and let me know whether it is suitable for your scenario.

    Regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    I'm getting a error with the following function. Do I need to add any code to my code behind file to execute the functions?
    Thanks...

     
    function pageLoad() {
            var listBox = $find('<%= radListBoxReport.ClientID %>');
            setPickers(listBox.get_selectedItem().get_value());
        }

  4. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    Here is an image file of the actual JScript runtime error.
  5. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    I got it. All is well. I had the wrong RadListBox ID: name.

    Thank you so much,

    Carlos C.
  6. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    2 things.
    1. Currently the Month to Date function shows the "Beginning of the Month" which is correct, however the Date value is going to the end of the month, when it should be showing "Today" (the current date). For example 12/1/2010 to 12/27/2010 and not 12/1/2010 to 12/31/2010.
    Can you show me how to update my function to show today's date?

    2. What would be the function for the "Year to Date" listbox item? For example 1/01/2010 to 12/27/2010. The Beginning of the year to today.

    Thank you,

    Carlos
  7. Answer
    Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 27 Dec 2010 Link to this post

    Hello Carlos,

    Straight onto your questions:

    1) Here is the code that should be modified:
    else if (sval == "2")
    {
        startDate.setDate(1);
    }

    2) This would be similar to the "Month to Date" option:
    else if (sval == "3")
    {
        startDate = new Date(startDate.getFullYear(), 0, 1);
    }

    Note that you won't need the getDaysInMonth method in this scenario.

    Best regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Carlos
    Carlos avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    Thank you so much.
Back to Top