rad time picker is not working and returning null always

2 posts, 1 answers
  1. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 26 Aug 2012 Link to this post


    I have rad time picker, and I have normal link button click event,
    in this click event, I am trying to use $find method to select rad time picker, but always find method return null value, here is my test project link

    (the link has been removed)
  2. Answer
    Vasil avatar
    1604 posts

    Posted 29 Aug 2012 Link to this post

    Hello Khaled,

    In your searchRecords.js you have this code:
    var picker = $find("<%=ddlMachines.ClientID%>");
    This will remain the same in the output js sent to the client. And when you click the button, you are trying to find element with ID= "<%=ddlMachines.ClientID%>", and there is no such element, so it fails to find it.

    The asp inline tags "<%=" in particular are executed only in the .aspx files. And such tags are not executed in the .js files. So If you use the "<%=ddlMachines.ClientID%>" is used in your searchRecord.aspx it will result in "ctl00_ContentPlaceHolder1_From_Time" which is the proper ClinetID of the picker for this page.
    $find("ctl00_ContentPlaceHolder1_From_Time") will return the object correctly.

    You have several options to resolve this. Easiest is to place your JS inside the user control.
    Another solution is to use sampler JS inside the control like:
    <script type="text/javascript">
        var picker = $find("<%=ddlMachines.ClientID%>");
    Then inside your .js file use directly the globally declared picker.

    Please note that we have deleted the link in your original post. If you need to share code with the rest of the forum, please upload only the code and not the assemblies. You should never share RadControls DLLs in public.

    All the best,
    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