Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Server-Side Events from WebDataMenu
posted

I am trying to create an application and use the WebDataMenu control. However, I've noticed that there are no server-side events to hook (that I can see) and when using client-side javascript to access the item (per this article), it always returns the key of the first item.

So, how do I capture server-side events that will allow me to tell which menu item was clicked?

Parents
No Data
Reply
  • 185
    Verified Answer
    posted

    Actually, I was able to figure this out myself. I did it using the following in the code-behind page.

    1. Add the event handler to the Page_Load.
    this.WebDataMenu1.ItemClick += new Infragistics.Web.UI.NavigationControls.DataMenuItemEventHandler(WebDataMenu1_ItemClick);

    2. Add the ItemClick event to be triggered on click, as specified in the event handler.
    protected void WebDataMenu1_ItemClick(object sender, Infragistics.Web.UI.NavigationControls.DataMenuItemEventArgs e)
    {
        
    switch (e.Item.Key)
         {
             
    case "Item1":
                   Response.Write(
    "Item1 was clicked.");
                  
    break;
             
    case "Item2":
                   Response.Write(
    "Item2 was clicked.");
                  
    break;
             
    case "Item3":
                   Response.Write(
    "Item3 was clicked.");
                  
    break;
             
    case "Item4":
                   Response.Write(
    "Item4 was clicked.");
                  
    break;
             
    default:
                   Response.Write(
    "No item clicked");
                  
    break;
         }
    }

Children
No Data