【发布时间】:2013-03-11 01:02:48
【问题描述】:
我已经阅读了很多关于此的文章和问题。但仍然没有找到我的案例的答案。 该函数处理事件。它根本不起作用 我的代码:
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Popup.aspx.cs"
Inherits="GG.UI.Popup" %>
...
<asp:DropDownList ID="LEDropdown" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="LEDropdown_Change" ></asp:DropDownList>
ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PopulateClist();
BindGrid();
}
}
protected void PopulateClist()
{
LEDropdown.Items.Clear();
LEDropdown.Items.Add(new ListItem("First Item", "First");
LEDropdown.Items.Add(new ListItem("Second Item", "Second");
LEDropdown.SelectedIndex = 0;
}
protected void LEDropdown_Change(object sender, EventArgs arg)
{
string selectedLE = ((DropDownList)(sender)).SelectedValue;
ClientScript.RegisterStartupScript(GetType(), "Alert", "alert('" + selectedLE + "');");
}
我尝试在此页面和母版页中使用EnableViewState="true"。没有成功。
函数 LEDropdown_Change 从未被调用过。
页面在选择后仍然回传。
还有另一个带有 OnClick 事件的按钮,它工作正常。
【问题讨论】:
标签: asp.net events drop-down-menu event-handling