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 TreeView
- Overview
- Using EO.Web TreeView
- TreeNode and TreeNodeGroup
- Look, Skin and Theme
- Style and Appearance
- Data Binding
- Handling Event
- 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
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
Using control's properties to define client-side event handler function name
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:
<eo:MenuItem OnClickScript="window.alert('hi!')"> </eo:MenuItem>
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:
<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. |
function your_handler(e, eventInfo)
{
...
}
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. |
<eo:Menu ClientSideOnItemClick="ToggleCheckStatus"> ... </eo:Menu>
Event Sequence
When a navigation item is clicked, client side events occur in the following order:
- ASP.NET client side validates if CausesValidation is set to true;
- Execute client side JavaScript defined in item's OnClickScript;
- Execute client side JavaScript function which name is specified in control's ClientSideOnItemClick;
- Redirect to NavigateUrl if specified;
- ASP.NET server side validates if CausesValidation evaluates to true;
- 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:
<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:JavaScriptfunction ClickHandler(e, eventInfo) { if (!window.confirm("Sure?")) eventInfo.cancel(); }
-
- OR -
Return false, for example:JavaScriptfunction ClickHandler(e, eventInfo) { if (!window.confirm("Sure?")) return false; }