Javascript interaction between ASP.NET web controls
<p>I have a UserControl A which contains </p>

<ul>
<li>a dropdown</li>
<li>a placeholder</li>
</ul>

<p>At runtime the placeholder will be populated with some UserControl B.</p>

<p>There are certain times which I need to trap the javascript onchange event in the dropdown to call a javacript function in B (to do a clientside update of B). What is a good design/practice for how to do this? </p>

<p>The naive way is to make the asp:dropdownlist a public member then send it into a public method of B:</p>

<pre><code>// In controlling code
...
userControlB.Initialize(userControlA.TheDropDownList);
...


// In usercontrol B
public void Initialize(DropDownList dropdownFromA)
{
    dropdownFromA.Attributes.Add("onchange", "myBfunction()");
}
</code></pre>

<p>But something smells bad with this approach. I would like to keep A and B as loosely coupled as possible. Any better ideas?</p>
