How can i get a button using its ID in a user control in ASP.NET?
<p>I have made a user control (.ascx) consisting of a div containing six buttons.
It has a string attribute "selectedButton" containing the value of the ID of one of the buttons.</p>

<p>What i would like to do is to be able to change the backcolor of the button whose ID corresponds to the selectedButton attribute when the page loads.</p>

<p>Right now I'm doing a switch in the ascx.cs on the value of the selectedButton attribute, like so :</p>

<pre><code>switch (selectedButton)
{
  case "Button1":
  Button1.BackColor = System.Drawing.ColorTranslator.FromHtml("#00CC00");
  break;
  //etc...
}
</code></pre>

<p>It works, but that doesn't seem very efficient, nor is it dynamic should i ever have more buttons.</p>

<p>I've tried putting this in the ascx source :</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var sb = document.getElementById("&lt;%=this.selectedButton %&gt;");
    sb.BackColor = System.Drawing.ColorTranslator.FromHtml("#00CC00");
&lt;/script&gt;
</code></pre>

<p>But without any results.</p>

<p>Thanks in advance.</p>
