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

Getting access to client side api dynamically?

2 Answers 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
C
Top achievements
Rank 1
C asked on 30 Mar 2015, 09:46 AM
Situation:

I have a RadTooltipManager, containing a web user control (WUC). This WUC in turn contains a number of telerik controls. Among these controls, a RadButton and a RadCalendar. I want to have access to this RadCalendar's selected date property on the client, when clicking the RadButton.

So if I tie an OnClientClicked event to the button and put this event in the WUC. I get a reference error. I'm assuming this is because the <script> portion of the WUC isn't loaded when the button is loaded. (I load the control via Page.LoadControl on the containing page).

If I put the OnClientClicked function on the containing page, it loads just fine. Then comes, however, the problem of referring to the RadCalendar contained in the tooltip and WUC. Usually I'll do a $find() and enter the contorlname.ClientID, but that will give an error here, as the containing page is aware of no such control.

So my next idea was to use the telerik static client side library to get a reference to the control in question. And this seems to work! If I do a $telerik.radControls, I get an array of all the loaded controls on the page. Which seems to include those in the WUC.

How do I get access to the Telerik client side library from one of these objects?

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 30 Mar 2015, 10:16 AM

Hi,

Scripts added to the page during an AJAX request are not parsed by the browser, so you get the error. Such scripts must be registered according to the MS AJAX needs.

I am attaching here a basic example that shows how you can utilize the findControl() method as a reference.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
C
Top achievements
Rank 1
answered on 30 Mar 2015, 02:45 PM
Thanks a whole lot!
Tags
General Discussions
Asked by
C
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
C
Top achievements
Rank 1
Share this question
or