Hello Michael Dunbar,
Using $find("<%= SomeControl.ClientID %>") is the recommended way to get reference to client-side objects. What it does it to output the generated client-id in the final markup of your page.
The $find() routine may fail in the occasion when the control is not yet initialized. All ASP.NET Ajax controls are initialized when the page is fully loaded - the required initialization statements are output at the end of the page just before closing the form tag. This means that the following will not work as the client-side object is not initialized:
<telerik:RadMenu runat="server" id="RadMenu1" />
var menu = $find("<%= RadMenu1.ClientID%>"); // menu will be null here
The workaround here is to register your code after control initialization. This can be done in the following ways:
- Use window.setTimeout. This would just delay the execution of your code and may need tweaking to find the timeout which works.
In your case it would be best to use the load event of the application. Emit that script using ScriptManager.RegisterStartupScript method. You can find examples in this
I hope this helps,
the Telerik team