C#下拉列表更改事件 [英] C# dropdownlist change event

查看:145
本文介绍了C#下拉列表更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < asp:DropDownList runat =serverID =myListDropDownCssClass =textOnSelectedIndexChanged =myListDropDown_Change/> 

有上面的aspx $ /

  protected void myListDropDown_Change(object sender,EventArgs e)
{
//从未得到的东西
}
/ pre>

我在myListDropDown方法上设置了一个断点,但它从未被击中。任何建议?

解决方案

设置 DropDownList 属性的系统.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 your DropDownList control to true.

<asp:DropDownList AutoPostBack="true" runat="server" ID="myListDropDown" 
                CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />

这篇关于C#下拉列表更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆