SelectedIndexChanged 不起作用!
我的代码:
*.aspx:
<asp:DropDownList ID="CountryList" CssClass="CountryList" runat="server"
OnSelectedIndexChanged="CountryList_SelectedIndexChanged" />
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
CountryList.SelectedIndexChanged +=
new EventHandler(CountryList_SelectedIndexChanged);
...
}
protected void CountryList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadCityList(CountryList, CityList);
}
但这不起作用。
My code:
*.aspx:
<asp:DropDownList ID="CountryList" CssClass="CountryList" runat="server"
OnSelectedIndexChanged="CountryList_SelectedIndexChanged" />
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
CountryList.SelectedIndexChanged +=
new EventHandler(CountryList_SelectedIndexChanged);
...
}
protected void CountryList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadCityList(CountryList, CityList);
}
But this doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试设置
AutoPostBack="true"
在此下拉列表中的 :您也不需要在
Page_Load
方法中手动连接事件处理程序。 ASP.NET 在编译 Web 表单时会自动完成此操作:Try setting
AutoPostBack="true"
on this dropdown list:Also you don't need to manually wire-up the event handler in the
Page_Load
method. It will be automatically done by ASP.NET when it compiles the webform:我认为您错过了 aspx 文件中的 AutoPostBack="true" 属性
I think you missed AutoPostBack="true" Property in aspx file
在你的 aspx 代码中添加 AutoPostBack="true" ,一切都会按照你的想法工作。
Add AutoPostBack="true" in ur aspx code and everything will work as you thought.