Tuesday, July 8, 2008

$get & $find functions in Javascript

These functions are defined in the ASP.NET AJAX client side library, there for you can use them only if you have included ScriptManager control of the ASP.NET AJAX.

$get - This function is equivelant of "document.getElementById" and "element.getElementById" functions. It points to "Sys.UI.DomElement.getElementById" JavaScript function which is defined as part of the ASP.NET AJAX client side library.

Syntax - var obj = $get(id,element);

element - optional (parent element to search, default is document element)

$find - Used to find component by its id. Generally used for fetching behavior of extender control.

Syntax - var obj = $find(id,parent)

parent - optional (parent element to search)


Reference - http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html