| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 648 人关注过本帖
标题:为什么会选一次追加一次?
只看楼主 加入收藏
Teem
Rank: 2
来 自:广东
等 级:论坛游民
帖 子:54
专家分:36
注 册:2012-12-24
结帖率:87.5%
收藏
 问题点数:0 回复次数:3 
为什么会选一次追加一次?
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
shangsharon
Rank: 9Rank: 9Rank: 9
来 自:湖北武汉
等 级:蜘蛛侠
威 望:7
帖 子:221
专家分:1261
注 册:2012-3-25
收藏
得分:0 
DropDownList1.Items.Add("Red");
        DropDownList1.Items.Add("Green");
        DropDownList1.Items.Add("Blue");
        DropDownList1.Items.Add("LightGray");

!IsPostBack
2013-07-30 23:53
飞年合
Rank: 2
等 级:论坛游民
帖 子:21
专家分:50
注 册:2013-7-29
收藏
得分:0 
if (!IsPostBack)
{
        DropDownList1.Items.Add("Red");
        DropDownList1.Items.Add("Green");
        DropDownList1.Items.Add("Blue");
        DropDownList1.Items.Add("LightGray");

}
2013-08-06 14:04
zhan10844120
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-8-19
收藏
得分:0 
摇钱树网吧管理软件经过四十多个版本升级,目前国内外2~3万家用户使用中,
稳定 安全性强!24小时免费技术支持
2013-08-19 13:58
快速回复:为什么会选一次追加一次?
数据加载中...
 
   



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

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