Newer RadControls version issue with setting default time in RadDateTimePicker

4 posts, 0 answers
  1. SVA Webmaster
    SVA Webmaster avatar
    11 posts
    Member since:
    Jul 2007

    Posted 29 Jan 2013 Link to this post

    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.

    <%@ 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">
    <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>

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 01 Feb 2013 Link to this post

    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
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SVA Webmaster
    SVA Webmaster avatar
    11 posts
    Member since:
    Jul 2007

    Posted 04 Feb 2013 Link to this post

    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. 

    1. Uncaught RangeError: Maximum call stack size exceeded ScriptResource.axd:5
      1. Sys.EventHandlerList.getHandlerScriptResource.axd:5
      2. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:823
      3. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      4. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      5. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      6. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      7. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      8. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      9. DateSelectedDefault.aspx:65
      10. (anonymous function)ScriptResource.axd:5
      11. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      12. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      13. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      14. (anonymous function)ScriptResource.axd:5
      15. (anonymous function)ScriptResource.axd:5
      16. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      17. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      18. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      19. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      20. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      21. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      22. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      23. DateSelectedDefault.aspx:65
      24. (anonymous function)ScriptResource.axd:5
      25. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      26. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      27. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      28. (anonymous function)ScriptResource.axd:5
      29. (anonymous function)ScriptResource.axd:5
      30. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      31. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      32. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      33. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      34. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      35. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      36. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      37. DateSelectedDefault.aspx:65
      38. (anonymous function)ScriptResource.axd:5
      39. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      40. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      41. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      42. (anonymous function)ScriptResource.axd:5
      43. (anonymous function)ScriptResource.axd:5
      44. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      45. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      46. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      47. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      48. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      49. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      50. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      51. DateSelectedDefault.aspx:65
      52. (anonymous function)ScriptResource.axd:5
      53. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      54. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      55. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      56. (anonymous function)ScriptResource.axd:5
      57. (anonymous function)ScriptResource.axd:5
      58. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      59. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      60. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      61. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      62. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      63. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      64. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      65. DateSelectedDefault.aspx:65
      66. (anonymous function)ScriptResource.axd:5
      67. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      68. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      69. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      70. (anonymous function)ScriptResource.axd:5
      71. (anonymous function)ScriptResource.axd:5
      72. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      73. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      74. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      75. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      76. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      77. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      78. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      79. DateSelectedDefault.aspx:65
      80. (anonymous function)ScriptResource.axd:5
      81. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      82. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      83. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      84. (anonymous function)ScriptResource.axd:5
      85. (anonymous function)ScriptResource.axd:5
      86. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      87. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      88. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      89. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      90. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      91. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      92. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      93. DateSelectedDefault.aspx:65
      94. (anonymous function)ScriptResource.axd:5
      95. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      96. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      97. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      98. (anonymous function)ScriptResource.axd:5
      99. (anonymous function)ScriptResource.axd:5
      100. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      101. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      102. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      103. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      104. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      105. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      106. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      107. DateSelectedDefault.aspx:65
      108. (anonymous function)ScriptResource.axd:5
      109. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      110. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      111. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      112. (anonymous function)ScriptResource.axd:5
      113. (anonymous function)ScriptResource.axd:5
      114. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      115. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      116. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      117. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      118. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      119. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      120. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      121. DateSelectedDefault.aspx:65
      122. (anonymous function)ScriptResource.axd:5
      123. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      124. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      125. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      126. (anonymous function)ScriptResource.axd:5
      127. (anonymous function)ScriptResource.axd:5
      128. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      129. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      130. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      131. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      132. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      133. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      134. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      135. DateSelectedDefault.aspx:65
      136. (anonymous function)ScriptResource.axd:5
      137. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      138. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      139. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      140. (anonymous function)ScriptResource.axd:5
      141. (anonymous function)ScriptResource.axd:5
      142. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      143. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      144. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      145. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      146. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      147. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      148. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      149. DateSelectedDefault.aspx:65
      150. (anonymous function)ScriptResource.axd:5
      151. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      152. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      153. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      154. (anonymous function)ScriptResource.axd:5
      155. (anonymous function)ScriptResource.axd:5
      156. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      157. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      158. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      159. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      160. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      161. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      162. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      163. DateSelectedDefault.aspx:65
      164. (anonymous function)ScriptResource.axd:5
      165. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      166. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      167. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      168. (anonymous function)ScriptResource.axd:5
      169. (anonymous function)ScriptResource.axd:5
      170. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      171. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      172. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      173. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      174. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      175. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      176. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      177. DateSelectedDefault.aspx:65
      178. (anonymous function)ScriptResource.axd:5
      179. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      180. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      181. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      182. (anonymous function)ScriptResource.axd:5
      183. (anonymous function)ScriptResource.axd:5
      184. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      185. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
      186. Telerik.Web.UI.RadInputControl._setNewValueScriptResource.axd:289
      187. Telerik.Web.UI.RadDateInput.set_valueScriptResource.axd:605
      188. Telerik.Web.UI.RadDateInput.set_selectedDateScriptResource.axd:595
      189. Telerik.Web.UI.RadDatePicker.set_selectedDateScriptResource.axd:148
      190. Telerik.Web.UI.RadTimeView.setTimeScriptResource.axd:59
      191. DateSelectedDefault.aspx:65
      192. (anonymous function)ScriptResource.axd:5
      193. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      194. Telerik.Web.UI.RadDatePicker.raise_dateSelectedScriptResource.axd:369
      195. Telerik.Web.UI.RadDatePicker._onDateInputValueChangedHandlerScriptResource.axd:329
      196. (anonymous function)ScriptResource.axd:5
      197. (anonymous function)ScriptResource.axd:5
      198. Telerik.Web.UI.RadWebControl.raiseEventScriptResource.axd:825
      199. Telerik.Web.UI.RadDateInput.raise_valueChangedScriptResource.axd:787
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Feb 2013 Link to this post

    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:
    <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.
Back to Top