本文介绍了C#下拉列表更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:DropDownList runat =serverID =myListDropDownCssClass =textOnSelectedIndexChanged =myListDropDown_Change/>
有上面的aspx $ /
protected void myListDropDown_Change(object sender,EventArgs e)
/ pre>
{
//从未得到的东西
}
我在myListDropDown方法上设置了一个断点,但它从未被击中。任何建议?
解决方案设置属性的系统.web.ui.webcontrols.listcontrol.autopostback.aspxrel =noreferrer>
code> control to
true
。< asp: DropDownList AutoPostBack =truerunat =serverID =myListDropDown
CssClass =textOnSelectedIndexChanged =myListDropDown_Change/>
<asp:DropDownList runat="server" ID="myListDropDown" CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />
There's the aspx above
protected void myListDropDown_Change(object sender, EventArgs e) { //stuff that never gets hit }
I put a break point on the myListDropDown method but it never gets hit. Any suggestions?
解决方案Set
AutoPostBack
property of yourDropDownList
control totrue
.<asp:DropDownList AutoPostBack="true" runat="server" ID="myListDropDown" CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />
这篇关于C#下拉列表更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!