Today I got an interview question as titled.
For example, a Update Panel contains a Panel, the Panel contains a TextBox.
How can I get the TextBox ClientID?
The only I could think of that is:
We can predict the TextBox ClientID depends on the ClientID mode and use getElementByID.
i.e.
getElementByID('ct100$MasterPageBody$ct100$UpdatePanelID$ct100$PanelID$ct100$TextBoxID')We can use JavaScript to parse the HTML, parse the input controls into arrays.
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)
getElementByID('<%=MyTextBox.ClientID%>')
But assuming the TextBox is added dynamic, but what's the proper way of doing it?