$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
NavigationBar Item Server Side Event in ASP.NET
Home > How to > NavigationBar Items Server Event

Information to Server-side Event

The PerNavigationBar control offers some server-side properties for each navigation item, using which you can easily control the item state and change the visualization of the entire navigation bar. And in this online tutorial, we will mainly illustrate three server-side events that are often used in customizing the settings of the navigation bar items.

Three Major Server-side Events

In this section, we will briefly introduce three server-side events that the PerNavigationBar control has provided, which are ItemClick, ItemCreated and ItemDataBound. Using these server-side events, you can let the navigation bar to respond in the code-behind when the users make a change on the navigation bar.
  • ItemClick Event: you can use this event handler in response to a click on a navigation bar item. This event is applied to all navigation bar items.
  • ItemCreated Event: you can use this event handler in response to a situation where a new item is added to the navigation bar at any level. To put it in another way, this event is raised when a new item is added to either the Items collection of the PerNavigationBar or the child items collection of certain navigation bar item. One thing that needs to be noted here is that if the navigation bar is bound to a data source, this ItemCreated event is triggered before the data binding.
  • ItemDataBound Event: you can use this event handler in response to a case that a navigation bar item is bound to a data source. This event is raised once an item has been bound to a data source. Thus, you can use this ItemDataBound event handler to initialize the properties of navigation bar items to reflect the values from the data source.

Programming Examples for Item Server-side Events

In this part, we will offer you the sample programming code which aims to guide you how to use above three item server side events handlers in ASP.NET web application. If you have any problem in initiating these server side event handlers, please feel free to contact us.

ASPX

<kettic:PerNavigationBar runat="server" ID="PerNavigationBar1" Height="300" OnItemClick="PerNavigationBar1_ItemClick">
</kettic:PerNavigationBar>

C# code

protected void PerNavigationBar1_ItemClick(object sender, Kettic.ASPX.Controls.PerNavigationBarEventArgs e)
{
if (e.Item.Items.Count > 0)
{
if (e.Item.Expanded == false)
{
Label1.Text = "Collapsed panel item - " + e.Item.Text;
}
else
{
Label1.Text = "Expanded panel item - " + e.Item.Text;
}
}
else
{
Label1.Text = "Clicked panel item - " + e.Item.Text;
}
}
Apart from these item server side events, the PerNavigationBar control also offers client side events for users to fully customize the creation of navigation bar in web application. To view more, please read this Navigation Bar Client Side Programming Tutorial.
ASP.NET AJAX UI Controls