If you use jQuery, you will have:
$('#elementId').change(function() { alert('Do Stuff'); });
or MS AJAX:
$addHandler($get('elementId'), 'change', function(){ alert('Do Stuff'); });
Or in a raw HTML element:
<input type="text" onchange="alert('Do Stuff');" id="myElement" />
After re-reading the question, I think I missed a reading of what was supposed to be done. I have never found a way to update the DOM element in a way that will cause a change event, what you are best doing is to have a separate event handler method, for example:
$addHandler($get('elementId'), 'change', elementChanged); function elementChanged(){ alert('Do Stuff!'); } function editElement(){ var el = $get('elementId'); el.value = 'something new'; elementChanged(); }
Since you are already writing a JavaScript method that will change it only 1 extra line to call.
Or, if you use the Microsoft AJAX framework, you can access all event handlers through:
$get('elementId')._events
This will allow you to perform some reflection-style actions to find the appropriate event handler to trigger.
Aaron Powell Sep 25 '08 at 22:36 2008-09-25 22:36
source share