Here is the rendered output from my page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>Untitled Page</title></head>
<body>
<form name="aspnetForm" method="post" action="child.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTAzNzI3NDIwMGRkZWiDaQtY8r7RUqQI1w/SRH9RC8k=" />
</div>
<div>
<div>
<label id="ctl00_ph_lbl">label</label>
<input name="ctl00$ph$txt" type="text" id="ctl00_ph_txt"
value="textbox" />
<button id="ctl00_ph_btn" onclick="test()" value="abcdefg">
</button>
</div>
<script type="text/javascript" language="javascript">
function test(){
alert(ctl00_ph_lbl.innerText);
alert(document.aspnetForm.ctl00_ph_txt.value);
}
</script>
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION"
id="__EVENTVALIDATION"
value="/wEWAgLYyMeTBwLaocbcB+Tmua4QHW6PavIEFZo2N7QLNNk9" />
</div>
</form>
</body>
</html>
In the javascript, how come I have to add "document.aspnetForm" before the
clientId code on the input control but not on the label control? If I omit
"document.aspnetForm" from the alert line for the input control, I get the
error message "ctl00_ph_txt is undefined". Is there some definition of when
a control needs this and when it doesn't?