62,271
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="111111.aspx.cs" Inherits="_111111" %>
<!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" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>111</asp:ListItem>
<asp:ListItem>222</asp:ListItem>
<asp:ListItem>333</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
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;
public partial class _111111 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("我变了!");
}
}
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.SelectedIndexChanged += new EventHandler(DropdownChanged);
}
protected void DropdownChanged(object sender, EventArgs e)//随便一个方法,只要有这2个参数即可用delegate挂载
{
Label1.Text = (DropDownList1.SelectedItem.Text);
}