This is a migrated thread and some comments may be shown as answers.

rad time picker is not working and returning null always

1 Answer 44 Views
Input
This is a migrated thread and some comments may be shown as answers.
khaled jendi
Top achievements
Rank 1
khaled jendi asked on 26 Aug 2012, 01:18 PM
hi,

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)

1 Answer, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 29 Aug 2012, 07:53 AM
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.
Then
$find("ctl00_ContentPlaceHolder1_From_Time")
$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%>");
</script>
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,
Vasil
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.
Tags
Input
Asked by
khaled jendi
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or