刚学NET,有个问题请教,关于DropDownList
运行后,改变DropDownList 的值后,什么都没有发生。我是照着一本教材做的。不知道哪里错了呢?
////////////////////////////////////////////////////////////////
<form id="form1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="false">
<asp:ListItem Value="123">123</asp:ListItem>
<asp:ListItem Value="456">456</asp:ListItem>
<asp:ListItem Value="789">789</asp:ListItem>
<asp:ListItem Value="abc">abc</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
////////////////////////////////////////////////////////////
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.SelectedItem.Value;
}
}