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

$find Versus getElementById

3 Answers 590 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ravi Kirpane
Top achievements
Rank 1
Ravi Kirpane asked on 06 Apr 2009, 03:06 PM
Can someone point me to a document with information that details difference between $find and getElementById?

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 06 Apr 2009, 03:33 PM
Hello Ravi,

Some helpful links are shown below:
$find shortcut method
$get shortcut method
getElementById method

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
mark
Top achievements
Rank 1
answered on 23 Apr 2009, 10:40 PM
Hi   Ravi

It is interesting that you ask this question as I have found different results when using both these options 

var findtextbox =$find(

"<%=RadTextBoxFirstName.ClientID %>") ;
var doctextbox = document.getElementById('<%= me.FindControl("RadTextBoxFirstName").ClientID %>');

 

findtextbox.set_value("Some value");  // success

doctextbox.set_value("Some value"); // yields an error

findtextbox.value ="Some value";  // success
doctextbox.value ="Some value";  // success

it would be nice if anyone can shed some light on this.


thanks
Mark

0
Daniel
Telerik team
answered on 24 Apr 2009, 06:39 AM
Hello Mark,

Our controls are based on the Microsoft AJAX framework. In order to get a reference to a component object on the client-side, so that you can use its API, you should use the short-hand method $find, which is part of the Microsoft AJAX client library.
ASP.NET AJAX documentation - $find Shortcut Method

There is no way to attain the same using getElementById because it returns an HTML DOM object, not a control instance.
HTML DOM getElementById() Method

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Ravi Kirpane
Top achievements
Rank 1
Answers by
Daniel
Telerik team
mark
Top achievements
Rank 1
Share this question
or