各位大哥大姐 小弟刚学ASP.NET 好多东西还都不明白希望大家能给我点帮助 请问大家 怎样用 Dropdownlist 控件改变 网页背景颜色 不用脚本语言

解决方案 »

  1.   

    <body id="aaa" runat="server" enableviewstate="false">//设置为服务器控件
    <form id="gaga" runat="server" method="get">
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="133px">
    <asp:ListItem Value="blue">蓝</asp:ListItem>
    <asp:ListItem Value="red">红</asp:ListItem>
    </asp:DropDownList>

    </form>
    </body>.cs
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
    this.aaa.Attributes.Add("bgcolor", DropDownList1.SelectedItem.Value);
    }