$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ComboBox Server Side Event in ASP.NET
Home > How to > ComboBox Server Event
What are the asp.net combobox server-side events used for? Sometimes, the ComboBox Control may have to respond to the events with complex actions. And these complex actions can not be performed using client-side APIs. Under this condition, we may need to trigger the server-side events in response to these complex actions. And the asp.net ComboBox Control offers several server-side events and APIs which will be fully illustrated in this guiding page.

Available Server-side Events for ComboBox Control

Here we demonstrate a list of server-side events that are supported by the web ComboBox Control.
  • ItemsRequested: this server-side event is called when the load-on-demand mechanism needs to add items to the combobox.
  • ItemCreated: this event fires when a new item is added to the items collection of the combobox object.
  • ItemDataBound: this event is raised when an item is being bound to a data value.
  • SelectedIndexChanged: this event is raised when the selected item has been just changed.
  • TextChanged: this event occurs when the text in the input area of combobox has been changed.
  • CheckAllCheck: this event occurs when the state of the check all items check box is changed.

How to Call Server-side Events of ComboBox Control

In this section, we offer you two methods to call above server-side events using ASP.NET AJAX. Note: for the page length, we just use four server-side events in following programming example. If you have any problems in using other server-side events, please feel free to contact us via E-mail.

How to Call Server-side Events in Aspx Web Page

<kettic:PerComboBox ID="PerComboBox1" runat="server" 
Height="140px" Width="150px"
AllowCustomText="True" AutoPostBack="true"
OnTextChanged="PerComboBox1_TextChanged"
OnItemChecked="PerComboBox1_ItemChecked" OnSelectedIndexChanged="PerComboBox1_SelectedIndexChanged"
OnCheckedChanged="SimpleRenderingMode_CheckedChanged"
>
</kettic:PerComboBox>

How to Trigger Server-Side Events Using C# Code

protected void PerComboBox1_CheckedChanged(object sender, EventArgs e)
{
if (PerComboBox1.Checked)
{
PerComboBox1.Checked = false;
PerComboBox1.RenderMode = RenderMode.Classic;
PerComboBox1.CheckBoxes = true;
}
else
{
PerComboBox1.CheckBoxes = false;
}
}

protected void PerComboBox1_SelectedIndexChanged(object sender, PerComboBoxSelectedIndexChangedEventArgs e)
{
if (PerComboBox1.SelectedItem != null)
{
EventLogConsole1.Text += String.Format("Currently selected item: '{0}'<br/>", PerComboBox1.SelectedItem.Text);
}
}

protected void PerComboBox1_TextChanged(object sender, EventArgs e)
{
EventLogConsole1.Text += (String.Format("Text changed to: '{0}'<br>", PerComboBox1.Text));
}

protected void PerComboBox1_ItemChecked(object sender, PerComboBoxItemEventArgs e)
{
EventLogConsole1.Text += (String.Format("Item '{0}' '{1}'<br/>", e.Item.Text, e.Item.Checked ? "checked" : "unchecked"));
}

Related ASP.NET Programming Events and APIs

If you want to let the ComboBox Control to detect and respond to the actions that are performed by end users, you can visit this online tutorial page for ASP.NET Client-side events of ComboBox Control.
ASP.NET AJAX UI Controls