Table of Contents
  • Getting Started
  • EO.Pdf
  • EO.Web
    • Overview
    • Installation & Deployement
    • EO.Web ToolTip
    • EO.Web Rating
    • EO.Web Slider & RangeSlider
    • EO.Web ListBox
    • EO.Web ComboBox
    • EO.Web Captcha
    • EO.Web ASPX To PDF
    • EO.Web Slide
    • EO.Web Flyout
    • EO.Web EditableLabel
    • EO.Web ImageZoom
    • EO.Web Floater
    • EO.Web Downloader
    • EO.Web ColorPicker
    • EO.Web HTML Editor
    • EO.Web File Explorer
    • EO.Web SpellChecker
    • EO.Web Grid
    • EO.Web MaskedEdit
    • EO.Web Splitter
    • EO.Web Menu
    • EO.Web Slide Menu
    • EO.Web TabStrip
    • EO.Web TreeView
    • EO.Web Calendar
    • EO.Web Callback
    • EO.Web MultiPage
    • EO.Web Dialog
    • EO.Web AJAXUploader
    • EO.Web ProgressBar - Free!
    • EO.Web ToolBar - Free!
  • EO.WebBrowser
  • EO.Wpf
  • Common Topics
  • Reference
Handling Client Side Events

Apply to

Menu, SlideMenu, TabStrip and TreeView

Overview

EO.Web navigation controls client side script offers several event interfaces to hook up customized event handlers. Using these events along with client side script interface empowers you to dynamically change the control without posting back to the server, for example, to check or uncheck an item, switch item text or icon.

This section covers these topics:

Using item's OnClickScript property to define client-side event handler code

You can use item's OnClickScript to handle OnClick event for each navigation item individually. For example:

ASPX
<eo:MenuItem 
    OnClickScript="window.alert('hi!')">
</eo:MenuItem>
OnClickScript is called before other defined event handlers are called.

Inside your script body, you can use global function eo_GetNavigatorEventInfo to retrieve a NavigatorEventInfo object that contains information about the control and item that raises the event. For example:

ASPX
<eo:MenuItem 
    OnClickScript="eo_GetMenuEventInfo().getItem().setChecked(true)">
</eo:MenuItem>

Using control's properties to define client-side event handler function name

You can also use control's properties to define the name of the client-side event handlers. The following lists the properties you can use:

Properties Remarks
Control's ClientSideOnItemClick property Specifies the name of the client function to be called when a navigation item is clicked.
Control's ClientSideOnItemMouseDown property Specifies the name of the client function to be called when user presses the mouse button on a navigation item.
Control's ClientSideOnItemMouseOver property Specifies the name of the client function to be called when mouse moves over the navigation item.
Control's ClientSideOnItemMouseOut property Specifies the name of the client function to be called when mouse cursor leaves a navigation item.
Control's ClientSideOnMouseOut property Specifies the name of the client function to be called when the mouse cursor leaves the control.
Control's ClientSideOnGroupExpand property Specifies the name of the client function to be called when a navigation item group is about to expand. This event is not available for TabStrip.
Control's ClientSideOnGroupCollapsed property Specifies the name of the client function to be called when a navigation item group has collapsed. This event is not available for TabStrip.
The above properties' value must be the name of a JavaScript function with the following definition:
JavaScript
function your_handler(e,  eventInfo)
{
   ...
}
The function will be called with two parameters when the event occurs:
Parameter Description
e For Microsoft Internet Explorer, this is window.event. For other browsers, it is the DOM event object.
eventInfo A NavigatorEventInfo object that contains information about the event.
The following example demonstrates how to toggle check/uncheck status for a navigation item when user clicks the item:
<eo:Menu 
    ClientSideOnItemClick="ToggleCheckStatus">
    ...
</eo:Menu>

Event Sequence

When a navigation item is clicked, client side events occur in the following order:

  1. ASP.NET client side validates if CausesValidation is set to true;
  2. Execute client side JavaScript defined in item's OnClickScript;
  3. Execute client side JavaScript function which name is specified in control's ClientSideOnItemClick;
  4. Redirect to NavigateUrl if specified;
  5. ASP.NET server side validates if CausesValidation evaluates to true;
  6. Execute server side ItemClick event handler;

Step 5 and 6 only occur if the control's "RaisesServerEvent" property is set to true.

Event Cancellation

You can cancel the OnClick event in event handling script. To cancel the event in OnClickScript, call global function eo_CancelEvent. For example:

ASPX
<eo:MenuItem 
    OnClickScript="if (!window.confirm('Sure?') eo_CancelEvent();">
</eo:MenuItem>

To cancel the clicked event in ClientSideOnItemClick, use any one of the following ways:

  • Call eo_CancelEvent, for example:
    JavaScript
    function ClickHandler(e, eventInfo)
    {
        if (!window.confirm("Sure?"))
            eo_CancelEvent();
    }
  • - OR -
    Call cancel on the eventInfo parameter, for example:
    JavaScript
    function ClickHandler(e, eventInfo)
    {
        if (!window.confirm("Sure?"))
            eventInfo.cancel();
    }
  • - OR -
    Return false, for example:
    JavaScript
    function ClickHandler(e, eventInfo) 
    { 
        if (!window.confirm("Sure?")) 
            return false; 
    }
Use any of the above functions can terminate the event handling sequence.