I have a JavaScript called common.js that is referenced by every ASPX in my
web application. In common.js, I have a funtion called findText (which I use
to help me navigate through drop down lists by typing the first few letters
of an item in the drop down list).
So this is how I would use it:
<input type="text" id="searchCompa ny" size="1" name="searchCom pany"
onkeyup="findTe xt(this, Company);">
<asp:dropdownli st ID="Company" Runat="server"> </asp:dropdownlis t>
All this is fine on a normal webform. But I run into trouble when my
dropdown list is inside a user control. Consider this pseudo HTML (as it
would look like after the page was rendered)
<html>
<head>
<script src='http://localhost/mywebapp/js/common.js'
language='JavaS cript'></script>
</head>
<form id="frmMain" runat="server">
<McAddEditAsc x User Control Rendered>
<input type="text" id="searchCompa ny" size="1"
name="searchCom pany" onkeyup="base.f indText(this, Company);">
<select name="_McAddEdi tAscx:Company"
id="_McAddEditA scx_Company">
<option value="somethin g">something </option>
...
</select>
</McAddEditAscx User Control Rendered>
</form>
</html>
Notice that when the UserControl got rendered my dropdownlist with
id="Company" was rendered as _McAddEditAscx: Company
I tried fugding my searchCompany box by doing
<input type="text" id="searchCompa ny" size="1" name="searchCom pany"
onkeyup="base.f indText(this, _McAddEditAscx: Company);">
I don't that's a clean solution though.
So how do I access HTML controls that are in a user control using
JavaScript?
THANK YOU!!