Hrushikesh Mokashi
Top achievements
Rank 1
Hrushikesh Mokashi
asked on 09 Jan 2009, 08:00 AM
Hi All,
I am using RadTimePicker.
I want to set the time in RadTimepicker from javascript.
Please help me.
Thanks
I am using RadTimePicker.
I want to set the time in RadTimepicker from javascript.
Please help me.
Thanks
8 Answers, 1 is accepted
0
Hello Hrushikesh,
Test the following approach:
RadTimePicker Client Object
RadDateInput Client Object
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Test the following approach:
var timePicker = $find('<%= RadTimePicker1.ClientID %>'); |
timePicker.get_dateInput().set_value("01:00 PM"); |
RadTimePicker Client Object
RadDateInput Client Object
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hrushikesh Mokashi
Top achievements
Rank 1
answered on 09 Jan 2009, 12:08 PM
Hi,
Thanks
The solution work.
Thanks
The solution work.
0
provident
Top achievements
Rank 1
answered on 11 Mar 2010, 04:48 AM
This is the solution I'm looking for as well, however I receive the message "object doesn't support this property or method" when I do the timePicker.get_dateInput().set_value() function. I actually receive this message any time I use the timePicker.get_ or set_ functions. My release is 2.2.4.
What I am trying to accomplish is to set the time field to 00:00:00 after some javascript validation from the OnDateSelected event that is using the SharedTimeView. If I select the time input textbox on the screen and click the Delete key, this provides me with exactly what I'm expecting - "00:00:00". I just haven't been able to accomplish the same thing from JavaScript client-side code.
The only thing that has worked so far is the timePicker.SetInputDate('') function, but this causes another postback. I was able to do a timePicker.GetTextBox from the DateInputID control and set the .innerText to null, which does clear the field on the screen, but somehow the original time value is still left in args.OldValue. I've been struggling with this for several days to no avail. Any help would be greatly appreciated.
Thanks,
Steve M. Dorris
What I am trying to accomplish is to set the time field to 00:00:00 after some javascript validation from the OnDateSelected event that is using the SharedTimeView. If I select the time input textbox on the screen and click the Delete key, this provides me with exactly what I'm expecting - "00:00:00". I just haven't been able to accomplish the same thing from JavaScript client-side code.
The only thing that has worked so far is the timePicker.SetInputDate('') function, but this causes another postback. I was able to do a timePicker.GetTextBox from the DateInputID control and set the .innerText to null, which does clear the field on the screen, but somehow the original time value is still left in args.OldValue. I've been struggling with this for several days to no avail. Any help would be greatly appreciated.
Thanks,
Steve M. Dorris
0
provident
Top achievements
Rank 1
answered on 11 Mar 2010, 05:19 AM
OK, I was able to accomplish my desired results with the following code, where (sender) is the RadTimePicker control. Just thought I'd publish the code in case it helped anyone else.
function ClearTextBox(sender) {
var rtp = $get(sender.ClientID) ;
rtp.value = '';
var rtpDateInput = $get(sender.DateInputID);
rtpDateInput.value = '';
var rtpTextBox = sender.GetTextBox(rtpDateInput);
rtpTextBox.innerText = '';
}
By the way, we've been using your Calender control in our commercial timesheet app for two years now and have received rave reviews. Thanks for a great product. We are now incorporting the RadTimePicker.
Steve M. Dorris
function ClearTextBox(sender) {
var rtp = $get(sender.ClientID) ;
rtp.value = '';
var rtpDateInput = $get(sender.DateInputID);
rtpDateInput.value = '';
var rtpTextBox = sender.GetTextBox(rtpDateInput);
rtpTextBox.innerText = '';
}
By the way, we've been using your Calender control in our commercial timesheet app for two years now and have received rave reviews. Thanks for a great product. We are now incorporting the RadTimePicker.
Steve M. Dorris
0
Chandan Dey
Top achievements
Rank 1
answered on 06 Dec 2011, 08:11 PM
Hi Daniel,
I am always getting null when use $find with my radtimepicker.
My Control :
<telerik:RadTimePicker ID="txtServiceTime" runat="server" Width="180px">
<DateInput runat="server" ID="DateInput" DateFormat="HH:mm" DisplayDateFormat="HH:mm" >
<ClientEvents OnLoad="onLoad" />
</DateInput>
</telerik:RadTimePicker>
My Javascript :
function onLoad(sender, args) {
debugger;
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
minutes = ((minutes < 10) ? "0" : "") + minutes;
var clock = hours + ":" + minutes; // + ":" + seconds
var time = new Date();
if (document.getElementById('<%= hdnClientTime.ClientID %>').value == "1") {
var timePicker = $find('<%= txtServiceTime.ClientID %>');
timePicker.get_dateInput().set_value(hours + ':' + minutes);
//time.setHours(hours);
//time.setMinutes(minutes);
I am always getting null when use $find with my radtimepicker.
My Control :
<telerik:RadTimePicker ID="txtServiceTime" runat="server" Width="180px">
<DateInput runat="server" ID="DateInput" DateFormat="HH:mm" DisplayDateFormat="HH:mm" >
<ClientEvents OnLoad="onLoad" />
</DateInput>
</telerik:RadTimePicker>
My Javascript :
function onLoad(sender, args) {
debugger;
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
minutes = ((minutes < 10) ? "0" : "") + minutes;
var clock = hours + ":" + minutes; // + ":" + seconds
var time = new Date();
if (document.getElementById('<%= hdnClientTime.ClientID %>').value == "1") {
var timePicker = $find('<%= txtServiceTime.ClientID %>');
timePicker.get_dateInput().set_value(hours + ':' + minutes);
//time.setHours(hours);
//time.setMinutes(minutes);
//timePicker.value(/time);
}
}
}
}
0
Princy
Top achievements
Rank 2
answered on 07 Dec 2011, 05:33 AM
Hello,
It shows null because the control was not rendered on OnLoad event. So you can access it using sender as shown below.
JS:
Thanks,
Princy.
It shows null because the control was not rendered on OnLoad event. So you can access it using sender as shown below.
JS:
<script type=
"text/javascript"
>
function
onLoad(sender, args)
{
var
time =
new
Date();
... ... ...
sender.set_textBoxValue(clock);
}
</script>
Thanks,
Princy.
0
Chandan Dey
Top achievements
Rank 1
answered on 07 Dec 2011, 05:34 PM
Hi Princy
First of all thanks a lot. It really working for me.
But there was a problem after populate the time in radtimepicker control if i click on that radtimepicker the value is erased.
And at the time of save the data in database SelectedDate property is null and i am using InvalidTextBoxValue prpperty to save in database it will work but is it a actual procedure to set client time in radtimepicker when a page load.
Thanks
Chandan
First of all thanks a lot. It really working for me.
But there was a problem after populate the time in radtimepicker control if i click on that radtimepicker the value is erased.
And at the time of save the data in database SelectedDate property is null and i am using InvalidTextBoxValue prpperty to save in database it will work but is it a actual procedure to set client time in radtimepicker when a page load.
Thanks
Chandan
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2011, 06:33 AM
Hello,
I suppose you want to store the current time in DB. So one suggestion is you can store that time in a Hiddenfield and access that in server side. Here is the sample code.
JS:
CS:
Thanks,
Princy.
I suppose you want to store the current time in DB. So one suggestion is you can store that time in a Hiddenfield and access that in server side. Here is the sample code.
JS:
function
onLoad(sender, args)
{
... ... ...
var
clock = hours +
":"
+ minutes;
sender.set_textBoxValue(clock);
document.getElementById(
"Hiddenfield1"
).value = clock;
}
protected
void
btn_Click(
object
sender, EventArgs e)
{
string
ctime= Hiddenfield1.Value;
}
Thanks,
Princy.