ComponentOne ComboBox for ASP.NET Web Forms
Quick Start / Step 3 of 4: Create an Event Handler for the Selected Item
In This Topic
    Step 3 of 4: Create an Event Handler for the Selected Item
    In This Topic

    In this topic the selectedItem event is triggered when an item in the combobox is selected.

    1. Select the Source tab and add the following script for the C1ComboBox1_OnClientChanged function before the <body> tag:        

      To write code in Client Side script

      <script id="scriptInit" type="text/javascript">
      
                  function C1ComboBox1_OnClientChanged(e, data) {
      
                      var val = data.selectedItem.value;
      
                      $('#output').html('I selected the ' + val + ' airfare option. ');
      
                  }    
      
      </script>
      
    2. Add a Label to the source page before the C1ComboBox tags so the Label appears above the C1ComboBox.       

      To write code in Source View

       <label id="output">
      
            Please select fare option.</label>
      

      The label should appear like the following

      C1ComboBox

    3. Within the C1ComboBox tags assign the onclientchanged="C1ComboBox1_OnClientChanged" function to the onclientchanged property so it appears like the following:        

      To write code in Source View

      <cc1:C1ComboBox ID="C1ComboBox1" runat="server" Width="160px"
                  onclientchanged="C1ComboBox1_OnClientChanged">