Skip to main content
Tab

ASPxNavBar.ItemClick Event

Fires after an item has been clicked.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public event NavBarItemEventHandler ItemClick

Event Data

The ItemClick event's data class is NavBarItemEventArgs. The following properties provide information specific to this event:

Property Description
Item Gets an item object related to the event.

Remarks

Write an ItemClick event handler to perform specific actions on the server side each time an item is clicked within the navbar control. Note that this event fires immediately after the left mouse button is released. If the button is released when the mouse pointer is not over an item, the event doesn’t fire. You can use the event parameter’s property to identify the clicked item.

Note

The server ItemClick event is not generated for items whose NavBarItem.NavigateUrl property’s value is defined.

Example

This example demonstrates how the server ItemClick event can be handled for an ASPxNavBar control. Note that if this event is handled, it is invoked regardless of the control’s AutoPostBack property setting.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxNavBar" 
TagPrefix="dxnb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">
     protected void Page_Load(object sender, EventArgs e) {

     }
     protected void ASPxNavBar1_ItemClick(object source, 
          DevExpress.Web.NavBarItemEventArgs e) {
         e.Item.Text += " is clicked";
         e.Item.Enabled = false;
     }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
 <head id="Head1" runat="server">
     <title>Enchancement for Server-Side ItemClick</title>
 </head>
 <body>
     <form id="form1" runat="server">
     <div>
         <dxnb:ASPxNavBar ID="ASPxNavBar1" runat="server" AllowExpanding="False" 
        ShowExpandButtons="False" OnItemClick="ASPxNavBar1_ItemClick">
             <Paddings Padding="0px" />
             <Groups>
                 <dxnb:NavBarGroup Text="Click on the item">
                     <Items>
                         <dxnb:NavBarItem Text="Item1" />
                         <dxnb:NavBarItem Text="Item2" />
                     </Items>
                 </dxnb:NavBarGroup>
             </Groups>
         </dxnb:ASPxNavBar>
     </div>
     </form>
 </body>
 </html>
See Also