Find Item by ID

2 posts, 0 answers
  1. Tab Alleman
    Tab Alleman avatar
    18 posts
    Member since:
    Apr 2010

    Posted 15 Jun 2010 Link to this post

    It seems to be the case that there is no way to find a menu item by its ID with server-side code.    Is this correct?   Please tell me I'm wrong.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jun 2010 Link to this post

    Hi,

    As far as I know, there is no direct method for RadMenu to access the item using ID. RadMenu allows accessing items according to url, text, value there is GetAllItems method to access all the RadMenuItems, which is described in the documentation.

    But, you can explicitly check for the item by iterating through all the items as shown in the sample code.

    CS:
     
        string value = "";              
        foreach (RadMenuItem item in RadMenu1.GetAllItems()) 
        { 
            if (item.Attributes["id"] == "id2")  // I set id attribute to each menuitem 
            { 
                value = item.Value; 
                break
            } 
        } 
        RadMenuItem findItem = RadMenu1.FindItemByValue(value); 
        findItem.Text = "Got the item"


    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top