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

2 related DatePickers

3 Answers 51 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 01 Apr 2009, 04:23 PM
Hi there,

I have 2 RadDatePicker controls on a page.  When a user picks a date from the first one, I want the second one to show a date that's one month later than the first one.

I am not having much success doing this.  Could you guys throw together a quick example that illustrates this?

thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 02 Apr 2009, 11:09 AM
Hello Jim,

Please try the following:
<script type="text/javascript" language="javascript"
    function dateSelected(sender, args) 
    { 
        var picker2 = $find('<%= RadDatePicker2.ClientID %>'); 
        var selDate = sender.get_selectedDate(); 
        picker2.set_selectedDate(new Date(selDate.setMonth(selDate.getMonth() + 1))); 
    } 
</script> 
 
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" ClientEvents-OnDateSelected="dateSelected" /> 
<telerik:RadDatePicker ID="RadDatePicker2" runat="server" /> 

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Daniel Tharp
Top achievements
Rank 1
answered on 01 Feb 2012, 08:08 PM
Hello,

I have 2 raddatepickers in a repeater control and I want to do the same thing as you mention. How would I access the other raddatepicker inside the repeater. I looked at the client object but I don't understand how to get the parent control and index so I can get to the other datepicker. Any help would be great.

thanks
0
Antonio Stoilkov
Telerik team
answered on 06 Feb 2012, 07:34 AM
Hi Daniel,

You could achieve your scenario by getting the naming container prefix and appending it to the second RadDatePicker id as it is shown in the example below.
var namingContainer = sender.get_id().substring(0, sender.get_id().search("RadDatePicker1"));
var radDatePicker2 = $find(namingContainer + "RadDatePicker2");


Kind regards,
Antonio Stoilkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Input
Asked by
Jim
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Daniel Tharp
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or