TreeView’s TreeNodeCheckChanged and Firefox

Let’s create a TreeView control with checkboxes and a define a TreeNodeCheckChanged event:

Unfortunately, this definition alone does not generate the required code that fires the TreeNodeCheckChanged event when a checkbox is changed. We need to manually fire this event with Javascript:

Older versions of Internet Explorer define the window.event object (which also exists for newer versions of Internet Explorer and Chrome), however this object is undefined for other modern browsers such as Firefox. Modern web browsers (including newer versions of Internet Explorer) define instead. By checking whether e is defined, we can use for modern web browsers, including Firefox, otherwise we use window.event.srcElement for older versions of Internet Explorer.

Next, we need to bind the onClientTreeNodeCheckChanged javascript function to the TreeView control:

Finally, add the TreeNodeCheckChanged event to your code behind file:

And you’ve now got everything you need to run the TreeNodeCheckChanged event for both modern web browsers and older versions of Internet Explorer.


Thanks to:


Leave a Reply