.NET Daily

Javascript

JavaScript events applied to a Dropdown control

Posted on .

JavaScript events applied to a Dropdown control

Introduction

Have you ever tried to dynamically open a dropdown control from a JavaScript event? Well, I’m not going to show you that because for the moment that’s almost impossible. It works only on Chrome browser. I’ve tried several tricks like assigning custom JavaScript triggers to a select tag but nothing worked on other browsers. Maybe we’ll have to wait for HTML 6 for that…

What I am going to show you though, is what other JavaScript events can be applied to a dropdown control.

The ASP.NET dropdown control generates into the page an HTML <select> element so all the working JavaScript events are referenced from that element. Below are the events:

  • onChange – Occurs after a value is selected from the dropdown.
  • onFocus – Occurs after the dropdown gains focus. It triggers the JavaScript event before the dropdown is opened.
  • onBlur – Occurs after a value is selected from the dropdown and the focus is removed from it.
  • onKeyDown – Occurs after a keyboard key is pressed when the dropdown is opened or when the dropdown has the focus.
  • onKeyDown – Occurs after a keyboard key is released when the dropdown is opened or when the dropdown has the focus.
  • onClick – Occurs after a dropdown is clicked.
  • onMouseOver – Occurs after the dropdown is hovered with the mouse cursor.
  • onMouseUp – Occurs after the dropdown is clicked and the click button is released.
  • onMouseDown – Occurs after the dropdown is clicked. Works similar to the onClick event but it triggers the JavaScript event before the dropdown values are expanded.

If I missed any event that can be applied to a dropdown control, please write it in the comments section.

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

There are no comments.

View Comments (0) ...
Navigation

Privacy Preference Center