1 Answer, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 13 May 2013, 12:50 PM
Hi Jiju,
Please have a look at the following code I tried which works fine at my end.
ASPX:
JavaScript:
Thanks,
Shinu.
Please have a look at the following code I tried which works fine at my end.
ASPX:
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
>
</
telerik:RadDatePicker
>
<
telerik:RadTimePicker
ID
=
"RadTimePicker1"
runat
=
"server"
>
</
telerik:RadTimePicker
>
<
br
/>
<
br
/>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
AutoPostBack
=
"false"
Text
=
"Get Date and Time"
OnClientClicked
=
"OnClientClicked"
>
</
telerik:RadButton
>
JavaScript:
<script type=
"text/javascript"
>
function
OnClientClicked(sender, args) {
var
datePicker = $find(
"<%=RadDatePicker1.ClientID %>"
);
var
timepicker = $find(
"<%=RadTimePicker1.ClientID %>"
);
var
selectedDate = datePicker.get_selectedDate().format(
"yyyy/MM/dd"
);
var
selectedTime = timepicker.get_selectedDate().format(
"HH:mm:ss"
)
alert(selectedDate +
" "
+ selectedTime);
}
</script>
Thanks,
Shinu.
Mayur
commented on 07 Nov 2013, 09:30 AM
Top achievements
Rank 1
Thanks Princy,
Your blog really helped me to resolve a big issue in my project. I would be always thankful to you.
Your blog really helped me to resolve a big issue in my project. I would be always thankful to you.
Liviu
commented on 09 Feb 2015, 12:36 PM
Top achievements
Rank 1
Hello Princy,
I see that everywhere is used $find("<%=RadTimePicker1.ClientID %>"); to get a reference to the timePicker object. This works fine if the timePicker control is a static element added to the asp page.
But, what if the timePicker control is a column from a grid(table), and is bound to a list, so it will be generated dynamically, according to the datasource.
e.g:
In this case, doesn't seem to work $find("<%=timePickToHour.ClientID %>") because I get the following error:
"The name 'timePickToHour' does not exist in the current context."
What I need to achieve is to get the value of two RadTimePicker from the same table row and to calculate the difference between them.
Can you help me with this please?
I see that everywhere is used $find("<%=RadTimePicker1.ClientID %>"); to get a reference to the timePicker object. This works fine if the timePicker control is a static element added to the asp page.
But, what if the timePicker control is a column from a grid(table), and is bound to a list, so it will be generated dynamically, according to the datasource.
e.g:
<asp:TemplateField HeaderText="End time">
<ItemTemplate>
<telerik:RadTimePicker ID="timePickToHour" runat="server" SelectedDate ='<%# Bind("ToHour") %>' Width="70px"></telerik:RadTimePicker>
</ItemTemplate>
</asp:TemplateField>
In this case, doesn't seem to work $find("<%=timePickToHour.ClientID %>") because I get the following error:
"The name 'timePickToHour' does not exist in the current context."
What I need to achieve is to get the value of two RadTimePicker from the same table row and to calculate the difference between them.
Can you help me with this please?
Eyup
commented on 12 Feb 2015, 12:49 PM
Telerik team
Hi Liviu,
Once you have the grid row container, you can use the findControl and findElement methods to achieve this requirement. I am also sending a sample RadGrid web site to demonstrate a similar implementation. Please run the attached application and let me know if it helps you.
Regards,
Eyup
Telerik
Once you have the grid row container, you can use the findControl and findElement methods to achieve this requirement. I am also sending a sample RadGrid web site to demonstrate a similar implementation. Please run the attached application and let me know if it helps you.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Liviu
commented on 12 Feb 2015, 04:56 PM
Top achievements
Rank 1
Hi Eyup,
I did a quick check in console and seems to work, nice!
If I will encounter any problem after I'll modify my .js I will let you know, but I don't think it will be.
Thank you very much!
I did a quick check in console and seems to work, nice!
If I will encounter any problem after I'll modify my .js I will let you know, but I don't think it will be.
Thank you very much!
Alfonso
commented on 29 Apr 2015, 05:49 PM
Top achievements
Rank 1
FechaEntrevista = Convert.ToDateTime(this.rddtpckfechaentrvst.SelectedDate + this.rdtmpckhoraentrvst.SelectedTime);
Eyup
commented on 01 May 2015, 04:52 AM
Telerik team
Hi Alfonso,
I guess you replied to the initial query of getting the combined value of the picker controls. This is also an option if the developer prefers server-side approach. The pickers provide AutoPostback property which will automatically cause a postback to the server when a value is selected. And for final optimization, RadAjaxManager or RadAjaxPanel may be used to achieve smooth user experience.
Regards,
Eyup
Telerik
I guess you replied to the initial query of getting the combined value of the picker controls. This is also an option if the developer prefers server-side approach. The pickers provide AutoPostback property which will automatically cause a postback to the server when a value is selected. And for final optimization, RadAjaxManager or RadAjaxPanel may be used to achieve smooth user experience.
Regards,
Eyup
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Try the following javascript.
JS:
function
OnClientClick()
{
var
datePicker = $find(
"<%=RadDatePicker1.ClientID %>"
);
var
timepicker = $find(
"<%=RadTimePicker1.ClientID %>"
);
var
dt = datePicker.get_dateInput().get_selectedDate().format(
"yyyy/MM/dd"
);
var
time = timepicker.get_dateInput().get_value();
alert(dt +
" "
+ time);
}
Thanks,
Princy.
how can i get the datetime to a variable ?
I tried the below code but not working.
var selectedDate = new Date(datePicker.get_dateInput().get_selectedDate() + " " + timepicker.get_dateInput().get_value());
it returns null value.
thanks in advance
regards
Jiju