Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I bind a javascript event handler to the Ajax Control Toolkit combobox when textbox changed
    text
    copied!<p>I need a combobox for an ASP.NET project, so I decided to use the Ajax Control Toolkit combobox (<a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx</a>).</p> <p>I don't want to use the postback as I don't want the page reloaded, but I need to know when the text in the textbox is changed so I can call out to the server to persist the new list item.</p> <p>I am curious how I bind an onchange or onblur event to the input box that this combobox uses.</p> <p>This is my asp.net page:</p> <pre><code>&lt;%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %&gt; &lt;cc1:ComboBox ID="PlantDropDown" runat="server" OnInit="PlantDropDown_Init" DropDownStyle="DropDown" AutoCompleteMode="SuggestAppend" ItemInsertLocation="OrdinalText" AutoPostBack="false"&gt; &lt;/cc1:ComboBox&gt; </code></pre> <p>Update: I tried using the suggestion and I get this error:</p> <pre><code>$find("PlantDropDown") is null [Break on this error] $find('PlantDropDown').add_propertyChanged(function(sender, e) {\r\n </code></pre> <p>I am using jQuery for the javascript side, btw, in case that helps.</p> <p>Final Update: I got it to work thanks to help from crescentfresh, and at the end I have this in my .aspx file:</p> <pre><code> &lt;input type="hidden" id="PlantDropDownID" value="&lt;%= PlantDropDown.ClientID %&gt;" /&gt; </code></pre> <p>And this is in my javascript file, since I don't push javascript in my .aspx file:</p> <pre><code>elem = document.getElementById('PlantDropDownID'); $find(elem.value).add_propertyChanged(function(sender, e) { if (e.get_propertyName() == 'selectedIndex') { var newValue = sender.get_textBoxControl().value; } }) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload