这个事Default.aspx的代码:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Ch2WebForm" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<p style="FONT-WEIGHT:bold;FONT-SIZE:12pt;COLOR:Maroon;
font-FAMILY:none;text-align:center">
This is my first ASP.NET form<br />
<br />
</p>
Select a color from the followint list,and then click the Button<br />
<p> 
<asp:DropDownList ID="ddlColorList" runat="server" Width="88px">
</asp:DropDownList>
<asp:Button ID="btnSelectColor" runat="server" Text="apply color"></asp:Button>
</p>
<p>
<asp:Label ID="lblSelectedColor" runat="server" Height="16px" Text="Label" Width="72px" AssociatedControlID="ddlColorList"></asp:Label>
</p>
</form>
</body>
</html>这个是Default.aspx.cs的代码:using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
public partial class Ch2WebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!(Page.IsPostBack))
{
ArrayList colors = new ArrayList(3);
colors.Add("Red");
colors.Add("green");
colors.Add("Blue");
ddlColorList.DataSource = colors;
ddlColorList.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
lblSelectedColor.Text = "You selected" +
ddlColorList.SelectedItem.Text;
lblSelectedColor.ForeColor =
System.Drawing.Color.FromName(ddlColorList.SelectedItem.Text);
}
}
程序显示如下结果:应该显示的效果是这样的:下图
请问是哪儿错了???
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<p style="FONT-WEIGHT:bold;FONT-SIZE:12pt;COLOR:Maroon;
font-FAMILY:none;text-align:center">
This is my first ASP.NET form<br />
<br />
</p>
Select a color from the followint list,and then click the Button<br />
<p> 
<asp:DropDownList ID="ddlColorList" runat="server" Width="88px">
</asp:DropDownList>
<asp:Button ID="btnSelectColor" runat="server" Text="apply color"></asp:Button>
</p>
<p>
<asp:Label ID="lblSelectedColor" runat="server" Height="16px" Text="Label" Width="72px" AssociatedControlID="ddlColorList"></asp:Label>
</p>
</form>
</body>
</html>这个是Default.aspx.cs的代码:using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
public partial class Ch2WebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!(Page.IsPostBack))
{
ArrayList colors = new ArrayList(3);
colors.Add("Red");
colors.Add("green");
colors.Add("Blue");
ddlColorList.DataSource = colors;
ddlColorList.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
lblSelectedColor.Text = "You selected" +
ddlColorList.SelectedItem.Text;
lblSelectedColor.ForeColor =
System.Drawing.Color.FromName(ddlColorList.SelectedItem.Text);
}
}
程序显示如下结果:应该显示的效果是这样的:下图
请问是哪儿错了???
解决方案 »
- 数组越界
- 第一次发贴,求教个奇怪的问题,困扰好久了,是关于HTTPS的SSL证书问题的,达人帮忙看下吧
- c#动态生成combobox的代码怎么写
- 求助,关于 C# 怎么用 Cult3D ActiveX Player 的
- 前台Table中空格得到焦点?
- 如果要用.NET做游戏,是C#还是VC++.NET好?
- ■■■■■■■数据层设计方案奥妙(高分请教)■■■■■■■■■■
- 求助:多页TIF图片如何保存到数据库中 C#
- GDI+问题,如何实现带有箭头的直线随着它指向的图行(如椭圆控件)的拖动而移动
- 高分求解xml问题,解决马上散分
- c#項目,如何用回車鍵提交某個按鈕?
- winform中如何将文件上传到服务器指定的路径
</asp:DropDownList>
少了事件