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

$find("radTxtB"); at window.onload doesn't work

3 Answers 51 Views
Input
This is a migrated thread and some comments may be shown as answers.
Fabiano Damasceno
Top achievements
Rank 1
Fabiano Damasceno asked on 25 Aug 2010, 06:27 PM
Hi,

If I run the jscript function [Disable] on a button click, it works perfect, but, when this function is called by the window.onload, I get a error. The error ocorre because $find doesn't return a valid object, instead, it return a null. Why this happen? There is a way to work around it?

window.onload = function() 
{
   Disable();
}
  
function Disable()
{
  var txt = $find("RadTextBox1");
  txt.disable();
}

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2010, 06:43 AM
Hello Fabiano,


Use the default pageLoad() method rather than window.onload. The cause of the problem is the control is not rendered on page when calling the window.onload method. The pageLoad fires only after all the ajaxified controls rendered on page.

function pageLoad()
{
   Disable();
}
   
function Disable()
{
  var txt = $find("RadTextBox1");
  txt.disable();
}



-Shinu.
0
Fabiano Damasceno
Top achievements
Rank 1
answered on 26 Aug 2010, 12:20 PM
Thanks for the tip Shinu, it works fine. :)
0
Dimo
Telerik team
answered on 26 Aug 2010, 12:44 PM
Hi Fabiano,

I recommend you the following page:

http://blogs.telerik.com/dimodimov/posts/08-12-13/don_t_use_body_onload_in_asp_net_ajax_websites.aspx

All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Input
Asked by
Fabiano Damasceno
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Fabiano Damasceno
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or