Topic: Referring to AJAX controls from JavaScript
Share/Save/Bookmark

Description: When using AJAX and JavaScript, previous JavaScript code that used "getElementByID" may not work with AJAX controls.

Notes: (none)


In order for your JavaScript to recognize controls contained within AJAX controls, such as UpdatePanel, you need to replace code, such as,

This is preferred:


var objExtendermain;
objExtenderMain = $find(
"<%=cpeMainNavigation.ClientID%>");


but, you can try this, as well:


window.document.getElementById(
"myControl").value = "SomeValue";


with the new AJAX functions.  Below is an example:


$get(
"myControl").value = "SomeValue";