Can't find Dynamically Created RadDatePicker in OnLoad

3 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Mar 2014

    Posted 01 Mar 2014 Link to this post

    I'm dynamically creating a RadDatePicker in the VB .NET code behind like so...

    Dim oCalCell As New HtmlTableCell()
    Dim oRadPicker As New Telerik.WebControls.RadDatePicker()
    oRadPicker.ID = "cldrStageDate"
    oRadPicker.Calendar.ID = "cldrStageDate_calendar"
    oRadPicker.Calendar.ClientEvents.OnLoad = "cldrLoaded"

    Then on the client side I have the following javascript code:

    function cldrLoaded(oCtl) {
       var sCtlId = null;
       if (typeof(oCtl.get_id) === "function") sCtlId = oCtl.get_id().split('_calendar')[0];
       else sCtlId = oCtl.ClientID; 
       var oCldr = $find(sCtlId);

    The control is rendered on the page and appears to be working.  But inside "cldrLoaded",  oCtl doesn't have a function named "get_id" when this function is called, but it does have a "ClientID" set.  But the $find(sCtlID) won't find the RadDatePicker.

    I have a DatePicker declared in the .aspx page that works as expected:

    <telerik:RadDatePicker id="cldrStageDate" runat="server">
       <Calendar ID="cldrStageDate_calendar" runat="server">
          <ClientEvents OnLoad="cldrLoaded" />

    How can I get the proper object get sent to the OnLoad function?


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Mar 2014 in reply to Daniel Link to this post

    Hi Daniel,

    Please have a look into the sample code snippet which works fine at my end.

    Protected Sub Page_Init(sender As Object, e As EventArgs)
        Dim radDatePicker1 As New Telerik.Web.UI.RadDatePicker()
        radDatePicker1.ID = "RadDatePicker1"
        radDatePicker1.Calendar.ClientEvents.OnLoad = "Load"
    End Sub

    <script type="text/javascript">
        function Load(sender, args) {
           //sender is the client side object to handle the control

  3. Daniel
    Daniel avatar
    2 posts
    Member since:
    Mar 2014

    Posted 03 Mar 2014 in reply to Shinu Link to this post

    Hi Shinu,

    Thank you for your comment and helpful solution!  Once I switched over to use the same object you did in your example, everything worked perfectly.

    Dim radDatePicker1 As New Telerik.Web.UI.RadDatePicker()
Back to Top