Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello

why method SelectedIndexChanged of combobox (of Ajaxcontroltoolkit) don't be run?

thanks

What I have tried:

i don't know what should i do for solve problem.


help
Posted
Updated 20-Nov-18 11:45am
Comments
F-ES Sitecore 20-Nov-18 10:17am    
Probably because you're not using it correctly.
Bryian Tan 20-Nov-18 12:39pm    
did you set AutoPostBack="True" ?

1 solution

Just like the standard ASP.NET DropDownList server control, you need to set AutoPostBack to True to trigger the SelectedIndexChanged event. Here's a quick example:

ASPX:

C#
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ComboBox ID="ComboBox1" runat="server" 
            DropDownStyle="DropDown" 
            AutoCompleteMode="None"
            CaseSensitive="false"
            RenderMode="Block"
            AppendDataBoundItems="true"
            AutoPostBack="True"
            OnSelectedIndexChanged="Combobox1_SelectedIndexChanged"
            >
              <asp:ListItem Text="One"></asp:ListItem>
              <asp:ListItem Text="Two"></asp:ListItem>
              <asp:ListItem Text="Three"></asp:ListItem>
</asp:ComboBox>


CODE BEHIND:
C#
void Combobox1_SelectedIndexChanged(object sender, EventArgs e)
{
        Response.Write("You've selected: " + ComboBox1.SelectedItem.Text);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900