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

Not able to access rad controls on page load

1 Answer 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Manoj asked on 15 Jul 2008, 10:32 AM

I have a page on which i have an iframe. On page i have a button and on its click i call a javascript method which loads a another page in the iframe.
Say the page loaded in iframe is named "MyPage".
On the page load event of MyPage i register a javascript method named "DisableDatePicker" that disables DatePicker control on MyPage. But when i try to access the Rad DatePicker inside this method i get it as null.
I am using Prometheus 2008 controls. 
i tried accessing DatePicker with following methods:
1.      <%= datePicker1.ClientId %> (this used to work for arlear rad controls)
2.      window['<%= datePicker1.ClientId %>']
3.      $find('<%= datePicker1.ClientId %>')

but nothing seems to work.
however if i access it as: document.getElementById('<%= datePicker1.ClientId %>') 
I get the object but that is does not possess the required properties and methods.

The same implementation used to work properly when we had old rad controls.
However if I access the controls after page load it works fine with new rad controls.

Please suggest me some solution.
 Manoj Dwivedi  

1 Answer, 1 is accepted

Sort by
Svetlina Anati
Telerik team
answered on 15 Jul 2008, 12:24 PM
Hi Manoj,

The controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls in the Sys.Application.add_init() method.

Here is how the client events are fired in the page life cycle:

window.onload -> Sys.Application.init -> Sys.Application.load

You can see that the client object representation of MS AJAX controls are created just as the last code on the page in the Sys.Application.init event, which is raised after the window.onload event.

That is why in order to correctly obtain a reference to the control's client object you should either execute your code with a small timeout, or use the Sys.Application.add_load method.

You can find additional information about this here.

Best wishes,
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question