How to get nested control's ClientID using JavaScript?
<p>Today I got an interview question as titled.</p>

<p>For example, a Update Panel contains a Panel, the Panel contains a TextBox.  </p>

<p>How can I get the TextBox ClientID?</p>

<p>The only I could think of that is:</p>

<ol>
<li><p>We can predict the TextBox ClientID depends on the ClientID mode and use getElementByID. </p>

<p>i.e. <code>getElementByID('ct100$MasterPageBody$ct100$UpdatePanelID$ct100$PanelID$ct100$TextBoxID')</code></p></li>
<li><p>We can use JavaScript to parse the HTML, parse the input controls into arrays.</p>

<p>i.e Assume we know we want to find the first UpdatePanel's first Panel's first TextBox.
We can find it from myUpdatePanel[0] then get its children using JavaScript? (I am only guessing here)</p></li>
<li><p><code>getElementByID('&lt;%=MyTextBox.ClientID%&gt;')</code></p></li>
</ol>

<p>But assuming the TextBox is added dynamic, but what's the proper way of doing it?</p>
