0
我已经通过了许多文章和关于此问题。但仍然没有找到我的情况的答案。 该函数处理事件。它不会在所有 我的代码工作:ASP Dropdown OnSelectedIndexChange事件不会触发
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事件按钮,它工作正常。
对不起,我的错。我编辑了函数名称,因此它更短,更易于阅读......不是这个问题。我更新了我的问题。感谢您的发现。 – Shinigamae 2013-03-11 01:59:14