Passing id and finding the element in javascript
<p>I'm extremely new to JavaScript and am stumped on this one.  I'm trying to send the <code>ClientID</code> of a <code>Control</code> to a js function.  The function should then find the element and get the <code>Control's</code> value.  To note: I am using a master page, and the <code>Control</code> I am passing the <code>ClientID</code> of is in a <code>UserControl</code>.</p>

<p>ASP:</p>

<pre><code>//code here

&lt;asp:TableCell runat="server"&gt;
    &lt;asp:DropDownList runat="server" ID="variableDDL"/&gt;
    //some ListItems
&lt;/asp:Tablecell&gt;

//more cells here

&lt;asp:TableCell runat="server"&gt;
    &lt;asp:ImageButton runat="server" ID="iButton" ImageUrl="~/Images/iButton.png" OnClientClick="iButtonClick(&lt;%=variableDDL.ClientID%&gt;);"/&gt;
&lt;/asp:TableCell&gt;

//code here
</code></pre>

<p>.js:</p>

<pre><code>function iButtonClick(ClientID)
{
    var v = document.getElementById(ClientID);
    var val = v.value;
    alert(val);
}
</code></pre>

<p>Every time I click the button, nothing happens.  Changing the sent parameter to <code>&lt;%#variableDDL.ClientID%&gt;</code> does the same thing.  Changing it to <code>'&lt;%=variableDDL.ClientID%&gt;'</code> or <code>'&lt;%#variableDDL.ClientID%&gt;'</code> gives a null pointer error since it can't find the object.  The script is referenced correctly, and does fire if I change it to not accept a parameter and just produce an alert.  Anyone know what I'm doing wrong?</p>

<p>EDIT: The requested code is shown below.</p>

<p>ASP UserControl:</p>

<pre><code>protected void Page_Init(object sender, EventArgs e) {
    DataTable fields = (DataTable) Session["fields"];
    for(int i = 0; i &lt; fields.Rows.Count; i++)
    {
        variableDDL.Items.Add(new ListItem(fields.Rows[i]["Field"].ToString(), fields.Rows[i]["Field"].ToString();
    }
}
</code></pre>

<p>Rendered OnClick HTML:
<code>'&lt;%=variableDDL.ClientID%&gt;'</code> produces</p>

<pre><code>onclick="iButtonClick(&amp;#39;&amp;lt;%=variableDDL.ClientID%&gt;&amp;#39;);"
</code></pre>

<p><code>&lt;%=variableDDL.ClientID%&gt;</code> produces</p>

<pre><code>onclick="iButtonClick(&amp;lt;%=variableDDL.ClientID%&gt;);"
</code></pre>

<p><code>'&lt;%#variableDDL.ClientID%&gt;'</code> produces</p>

<pre><code>onclick="iButtonClick(&amp;#39;&amp;lt;%#variableDDL.ClientID%&gt;&amp;#39;);"
</code></pre>

<p><code>&lt;%#variableDDL.ClientID%&gt;</code> produces</p>

<pre><code>onclick="iButtonClick(&amp;lt;%#variableDDL.ClientID%&gt;);"
</code></pre>
