G
George Durzi
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="searchCompany" size="1" name="searchCompany"
onkeyup="findText(this, Company);">
<asp:dropdownlist ID="Company" Runat="server"></asp:dropdownlist>
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='JavaScript'></script>
</head>
<form id="frmMain" runat="server">
<McAddEditAscx User Control Rendered>
<input type="text" id="searchCompany" size="1"
name="searchCompany" onkeyup="base.findText(this, Company);">
<select name="_McAddEditAscx:Company"
id="_McAddEditAscx_Company">
<option value="something">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="searchCompany" size="1" name="searchCompany"
onkeyup="base.findText(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!!
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="searchCompany" size="1" name="searchCompany"
onkeyup="findText(this, Company);">
<asp:dropdownlist ID="Company" Runat="server"></asp:dropdownlist>
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='JavaScript'></script>
</head>
<form id="frmMain" runat="server">
<McAddEditAscx User Control Rendered>
<input type="text" id="searchCompany" size="1"
name="searchCompany" onkeyup="base.findText(this, Company);">
<select name="_McAddEditAscx:Company"
id="_McAddEditAscx_Company">
<option value="something">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="searchCompany" size="1" name="searchCompany"
onkeyup="base.findText(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!!