| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 652 人关注过本帖
标题:为什么会选一次追加一次?
取消只看楼主 加入收藏
Teem
Rank: 2
来 自:广东
等 级:论坛游民
帖 子:54
专家分:36
注 册:2012-12-24
结帖率:87.5%
收藏
 问题点数:0 回复次数:0 
为什么会选一次追加一次?
aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html xmlns="http://www.
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:DropDownList ID="DropDownList1" runat="server" Height="38px" Width="127px"
            AutoPostBack="True" Font-Bold="True" ForeColor="Black"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
   
    </div>
    </form>
</body>
</html>

aspx.cs代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DropDownList1.Items.Add("Red");
        DropDownList1.Items.Add("Green");
        DropDownList1.Items.Add("Blue");
        DropDownList1.Items.Add("LightGray");
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

        string color = this.DropDownList1.SelectedItem.Value;
        switch (color)
        {
            case "Red":
                this.DropDownList1.BackColor = System.Drawing.Color.Red;
                break;

            case "Green":
                this.DropDownList1.BackColor = System.Drawing.Color.Green;
                break;

            case "Blue":
                this.DropDownList1.BackColor = System.Drawing.Color.Blue;
                break;

            case "LightGray":
                this.DropDownList1.BackColor = System.Drawing.Color.LightGray;
                break;

            default:
                this.DropDownList1.BackColor = System.Drawing.Color.White;
                break;

        }
    }
}
搜索更多相关主题的帖子: PUBLIC server title 
2013-07-30 15:43
快速回复:为什么会选一次追加一次?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021394 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved