我看到这样一段代码:
<SELECT onchange="if(this.options[this.selectedIndex].value!=''){do_color('Label1',this.options[this.selectedIndex].value);}"size="1" name="do_color_frm">
OPTION selected>文本颜色</OPTION>
<OPTION style="COLOR: black; BACKGROUND-COLOR: black" value="Black">Black</OPTION>
<OPTION style="COLOR: red; BACKGROUND-COLOR: red" value="Red">Red</OPTION>
<OPTION style="COLOR: yellow; BACKGROUND-COLOR: yellow" value="Yellow">Yellow</OPTION>
OPTION style="COLOR: pink; BACKGROUND-COLOR: pink" value="Pink">Pink</OPTION>
<OPTION style="COLOR: green; BACKGROUND-COLOR: green" value="Green">Green</OPTION>
<OPTION style="COLOR: orange; BACKGROUND-COLOR: orange" value="Orange">Orange</OPTION>
<OPTION style="COLOR: purple; BACKGROUND-COLOR: purple" value="Purple">Purple</OPTION>
<OPTION style="COLOR: blue; BACKGROUND-COLOR: blue" value="Blue">Blue</OPTION>
<OPTION style="COLOR: beige; BACKGROUND-COLOR: beige" value="Beige">Beige</OPTION>
<OPTION style="COLOR: brown; BACKGROUND-COLOR: brown" value="Brown">Brown</OPTION>
<OPTION style="COLOR: teal; BACKGROUND-COLOR: teal" value="Teal">Teal</OPTION>
<OPTION style="COLOR: navy; BACKGROUND-COLOR: navy" value="Navy">Navy</OPTION>
<OPTION style="COLOR: maroon; BACKGROUND-COLOR: maroon" value="Maroon">Maroon</OPTION>
<OPTION style="COLOR: limegreen; BACKGROUND-COLOR: limegreen" value="LimeGreen">LimeGreen</OPTION>
</SELECT>

<asp:Label id="Label1" runat="server" Width="408px">ggggggggggggggggggggggg</asp:Label>
结果字体并没有变化,而且出错
那位大侠实验一下,看看是什么原因

解决方案 »

  1.   

    <form runat="server">
    <SELECT onchange="if(this.options[this.selectedIndex].value!=''){<%=Label1.ClientID%>.style.color=this.options[this.selectedIndex].value;}"size="1" name="do_color_frm">
    OPTION selected>文本颜色</OPTION>
    <OPTION style="COLOR: black; BACKGROUND-COLOR: black" value="Black">Black</OPTION>
    <OPTION style="COLOR: red; BACKGROUND-COLOR: red" value="Red">Red</OPTION>
    <OPTION style="COLOR: yellow; BACKGROUND-COLOR: yellow" value="Yellow">Yellow</OPTION>
    OPTION style="COLOR: pink; BACKGROUND-COLOR: pink" value="Pink">Pink</OPTION>
    <OPTION style="COLOR: green; BACKGROUND-COLOR: green" value="Green">Green</OPTION>
    <OPTION style="COLOR: orange; BACKGROUND-COLOR: orange" value="Orange">Orange</OPTION>
    <OPTION style="COLOR: purple; BACKGROUND-COLOR: purple" value="Purple">Purple</OPTION>
    <OPTION style="COLOR: blue; BACKGROUND-COLOR: blue" value="Blue">Blue</OPTION>
    <OPTION style="COLOR: beige; BACKGROUND-COLOR: beige" value="Beige">Beige</OPTION>
    <OPTION style="COLOR: brown; BACKGROUND-COLOR: brown" value="Brown">Brown</OPTION>
    <OPTION style="COLOR: teal; BACKGROUND-COLOR: teal" value="Teal">Teal</OPTION>
    <OPTION style="COLOR: navy; BACKGROUND-COLOR: navy" value="Navy">Navy</OPTION>
    <OPTION style="COLOR: maroon; BACKGROUND-COLOR: maroon" value="Maroon">Maroon</OPTION>
    <OPTION style="COLOR: limegreen; BACKGROUND-COLOR: limegreen" value="LimeGreen">LimeGreen</OPTION>
    </SELECT>

    <asp:Label id="Label1" runat="server" Width="408px">ggggggggggggggggggggggg</asp:Label></form>
      

  2.   

    xiahouwen(活靶子.NET) 运行不好使啊
      

  3.   

    我刚才又测试了一下 没有问题
    你试试把我贴的那段代码另存成一个aspx文件
    访问看看