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.
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.
Right now I'm doing a switch in the ascx.cs on the value of the selectedButton attribute, like so :
switch (selectedButton)
{
case "Button1":
Button1.BackColor = System.Drawing.ColorTranslator.FromHtml("#00CC00");
break;
//etc...
}
It works, but that doesn't seem very efficient, nor is it dynamic should i ever have more buttons.
I've tried putting this in the ascx source :
<script type="text/javascript">
var sb = document.getElementById("<%=this.selectedButton %>");
sb.BackColor = System.Drawing.ColorTranslator.FromHtml("#00CC00");
</script>
But without any results.
Thanks in advance.