Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using an Ajax Control Tool Kit Combobox in my project. I want to trigger a change event when I change the value of the Combobox. I goolgled it a lot but there are no proper solution.

The ajax combobox is comprised of a textbox, a button and a list. I figured out the textbox id and I am trying to provide a change event to it. The change event is not working. But it will trigger the blur,select events.

this is the bit of code that I am using for the change event. I am not able to figure out why the change event is not working.

$('#' + $('.DDlCmbEmpID')[0].id + '_TextBox').bind("change",function (event) {
        alert("Sample");
    });
share|improve this question

2 Answers 2

You can use this script to catch selected index changing on client:

$find("<%= XXXXXX.ClientID %>").set_selectedIndex = function (newIndex) {
     Sys.Extended.UI.ComboBox.prototype.set_selectedIndex.apply(this, [newIndex]);
     alert(newIndex);
 };

Substitute XXXXXX ion script above with server id (or BehaviorID if presented) of ComboBox extender. Put this script at very bottom of page (not putting into $(document).ready )

Sript below tested on this page: ComboBox Demonstration

 $find("ctl00_SampleContent_ComboBox1").set_selectedIndex = function (newIndex) {
     Sys.Extended.UI.ComboBox.prototype.set_selectedIndex.apply(this, [newIndex]);
     alert(newIndex);
 };
share|improve this answer
    
I am getting an error when is use this ** Microsoft JScript runtime error: Unable to set value of the property 'set_selectedIndex': object is null or undefined** –  Elegant Coder May 31 '13 at 12:27
    
Show your code. This should work. –  Yuriy Rozhovetskiy May 31 '13 at 12:42
ComboBox box = new ComboBox();

Set the autopostback property true

box.AutoPostBack = true; 

define the selected change event

box.SelectedIndexChanged += box_SelectedIndexChanged;

If server side code is not a restriction, this will solve your issue

share|improve this answer
    
Server side Code is a restriction. I want a purely javascript or jQuery solution. I have already implemented the serverside version. I want to reduce the load to the server. Thats why I am in search of a javascripot code. –  Elegant Coder May 31 '13 at 12:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.