ComponentOne Menu for ASP.NET AJAX: Working with the Client-Side Menu > Client-Side Events

Client-Side Events

C1Menu includes several client-side events that allow you to manipulate the menu items in the C1Menu control when an action such as clicking the item, hovering over or out of the menu item occurs. You can access these client-side events from the Properties window. To create a new client-side event using the Properties window, select the drop-down arrow next to a client-side event and select Add new client side handler.

 

 

Once you've added the client-side handler, Visual Studio will add a script to the Source view. That script will resemble the following:

<script id="ComponentOneClientScript" type="text/javascript">

function C1Menu1_OnClientItemMouseDown(item, domEvent){

  //

  // Put your code here.

  //

};

</script>

Each of the client-side events requires two parameters: the ID that identifies the sender C1Menu, in this example, C1Menu1, and an eventArgs that contains the data of the event.

You can use the sever-side properties, listed in the Client Side Event table, to specify the name of the JavaScript function that will respond to a particular client-side event. For example, to assign a JavaScript function called "ItemClick" to respond to the clicked item, you would set the OnClientItemClick property to "ItemClick".

 

 

The following table lists the events that you can use in your client scripts. These properties are defined on the server side, but the actual events or the name you declare for each JavaScript function are defined on the client side.

Client Side Event table

Event Server-Side Property Name

Event Name

Description

OnClientItemBlur

ItemBlur

Fires on client side when menu item looses focus.

OnClientItemChecked

ItemChecked

Fires on client side when menu item is checked.

OnClientItemClick

ItemClick

Fires on client side when menu item is clicked.

OnClientItemFocus

ItemFocus

Fires on client side when menu item is focused.

OnClientItemMouseDown

ItemMouseDown

Fires on client side when mouse is down on menu item.

OnClientItemMouseOut

ItemMouseOut

Fires on client side when mouse becomes out of a menu item.

OnClientItemMouseOver

ItemMouseOver

Fires on client side when mouse is over menu item.

OnClientItemUnChecked

ItemUnChecked

Fires on client side when menu item is unchecked.

These events are useful for providing client-side interactivity. With these events you can provide more control over C1Menu by controlling how the users interact with C1Menu. For example you can use the ItemMouseOver event to prevent submenu items from expanding when the user mouses over menu items or the ItemClick event to add, remove, or disable menu items when the user clicks on an existing menu item.

 


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.