开发者

Problem with adding an event to the combo

开发者 https://www.devze.com 2023-01-08 18:38 出处:网络
I have a combobox: <ext:ComboBox ID=\"cbGroup\" runat=\"server\" Width=\"150\" OnItemSelected=\"cbGroup_ItemSelected\">

I have a combobox:

<ext:ComboBox ID="cbGroup" runat="server" Width="150" 
        OnItemSelected="cbGroup_ItemSelected">
    </ext:ComboBox&g开发者_Go百科t;

and a method:

    protected void cbGroup_ItemSelected(object sender, EventArgs e)
    {
        FilterItemSelected(this, new EventArgs());
    }

when the item in the combobox is changed the method isnt triggered.

what am i missing?


I think you need AutoPostBack="true" on the control.


Based on what I know about the ASP.NET DropDownList control, I would say to look for an AutoPostBack property on the ComboBox and set it to true.


I don't know what component framework you're using, but the asp:DropDownList has the OnSelectedIndexChanged event which will be triggered when an item is selected, with the assumption that AutoPostBack is set to true:

<asp:DropDownList AutoPostBack="true" ID="cbGroup" runat="server" Width="150" OnSelectedIndexChanged="cbGroup_ItemSelected"></asp:DropDownList>

Update: As I mentioned in my comment to Philip Smith's answer, I think the problem is that you don't set AutoPostBack to true; without this setting, the control won't trigger the event on the server-side, since AutoPostBack is standard set to false

0

精彩评论

暂无评论...
验证码 换一张
取 消