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

How to bind a Listbox item to the datepicker

7 Answers 192 Views
Getting started with ASP.NET
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 21 Dec 2010, 09:55 PM
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

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Dec 2010, 04:00 PM
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.
0
Carlos
Top achievements
Rank 1
answered on 27 Dec 2010, 04:29 PM
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());
    }

0
Carlos
Top achievements
Rank 1
answered on 27 Dec 2010, 04:32 PM
Here is an image file of the actual JScript runtime error.
0
Carlos
Top achievements
Rank 1
answered on 27 Dec 2010, 04:40 PM
I got it. All is well. I had the wrong RadListBox ID: name.

Thank you so much,

Carlos C.
0
Carlos
Top achievements
Rank 1
answered on 27 Dec 2010, 05:15 PM
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
0
Accepted
Daniel
Telerik team
answered on 27 Dec 2010, 09:33 PM
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.
0
Carlos
Top achievements
Rank 1
answered on 27 Dec 2010, 10:32 PM
Thank you so much.
Tags
Getting started with ASP.NET
Asked by
Carlos
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Carlos
Top achievements
Rank 1
Share this question
or