SVA Webmaster
Top achievements
Rank 1
SVA Webmaster
asked on 29 Jan 2013, 07:20 PM
I've encountered an issue in trying to find a way to set the default time on a raddatetimepicker control. I found a solution posted in 2009 here (http://www.telerik.com/community/forums/aspnet-ajax/input/set-default-time-on-datetimepicker.aspx), however have discovered that the solution provided used a version of the controls from 2009. Using any of the more recent versions of the controls, including the most recent release, causes a stack overflow error.
This is a huge problem for the app I'm developing and need a way to fix it promptly. Ideally, Telerik would just put in a default time property for the designer like there should have been in the first place. Any help from you folks or Telerik personnel would be most appreciative.
Here is the markup. You can replicate the issue with a basic .aspx file and changing the reference between older 2009 controls and a current build.
This is a huge problem for the app I'm developing and need a way to fix it promptly. Ideally, Telerik would just put in a default time property for the designer like there should have been in the first place. Any help from you folks or Telerik personnel would be most appreciative.
Here is the markup. You can replicate the issue with a basic .aspx file and changing the reference between older 2009 controls and a current build.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
type
=
"text/javascript"
>
var isTimeSelected = false;
function DateSelected(sender, args) {
if (!isTimeSelected)
sender.get_timeView().setTime(null, 23, 59, 0);
isTimeSelected = false;
}
function ClientTimeSelected(sender, args) {
isTimeSelected = true;
}
</
script
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadDateTimePicker
ID
=
"RadDateTimePicker1"
runat
=
"server"
>
<
ClientEvents
OnDateSelected
=
"DateSelected"
/>
<
TimeView
ID
=
"TimeView1"
runat
=
"server"
OnClientTimeSelected
=
"ClientTimeSelected"
>
</
TimeView
>
</
telerik:RadDateTimePicker
>
</
div
>
</
form
>
</
body
>
</
html
>
3 Answers, 1 is accepted
0
Hi Craig,
Find attached a sample runnable application which demonstrates the required functionality and works as expected with the latest release of the RadControls for ASP . Net Ajax. Give it a try and let me know if it covers your requirements.
Kind regards,
Maria Ilieva
the Telerik team
Find attached a sample runnable application which demonstrates the required functionality and works as expected with the latest release of the RadControls for ASP . Net Ajax. Give it a try and let me know if it covers your requirements.
Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
SVA Webmaster
Top achievements
Rank 1
answered on 04 Feb 2013, 04:13 PM
Maria,
I still get the same error when I open your project, before I even try to integrate it into mine. When I run it just as you sent it to me and use the developer tools in Chrome, I can see the following error take place when I select a date from your datetimepicker. Although it technically works and I can get it to set the date, there is a hesitation before it does so because it appears to be looping several times as shown in the error below as it fills the stack.
I still get the same error when I open your project, before I even try to integrate it into mine. When I run it just as you sent it to me and use the developer tools in Chrome, I can see the following error take place when I select a date from your datetimepicker. Although it technically works and I can get it to set the date, there is a hesitation before it does so because it appears to be looping several times as shown in the error below as it fills the stack.
- Uncaught RangeError: Maximum call stack size exceeded ScriptResource.axd:5
-
Array.cloneScriptResource.axd:5
-
Sys.EventHandlerList.getHandlerScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:823
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
-
Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
-
Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
-
Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
-
Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
-
DateSelectedDefault.aspx:65
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
-
Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
-
(anonymous function)ScriptResource.axd:5
-
(anonymous function)ScriptResource.axd:5
-
Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
-
Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
-
0
Hi Craig,
I further tested the provided example and you are correct that the presented error appear. It actually rise as the setTime method cause the DateSelected event to fire and it goes to infinite loop. In order to prevent this issue you could simply set the isDateToBeSet flag to "false" like this:
I hope this helps.
Kind regards,
Maria Ilieva
the Telerik team
I further tested the provided example and you are correct that the presented error appear. It actually rise as the setTime method cause the DateSelected event to fire and it goes to infinite loop. In order to prevent this issue you could simply set the isDateToBeSet flag to "false" like this:
<script type=
"text/javascript"
>
var
isDateToBeSet =
true
;
function
DateSelected(sender, args)
{
if
(isDateToBeSet) {
isDateToBeSet =
false
;
sender.get_timeView().setTime(8, 23, 0,
null
);
}
}
function
PopupOpening(sender, args)
{
isDateToBeSet = args.get_popupControl().get_id().indexOf(
"timeView"
) != -1 ?
false
:
true
;
}
</script>
I hope this helps.
Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.