Get menu Items

3 posts, 1 answers
  1. MissioDei
    MissioDei avatar
    17 posts
    Member since:
    Aug 2008

    Posted 04 Jan 2011 Link to this post

    I am using a menu control to track a 5 step process where the user views 5 web pages. The menu corresponds to the 5 pages but I am using the menu as "step 1", "step2", etc..

    So when the user views a page, I want the corresponding menu graphic to show as completed. This would mean that by the time they reach step 5/page 5 ...all of the menu steps will show the completed graphic for the menu item

    Every time the user views one of the pages, I was just going to write a bool to a cookie. Here is an example:

       public Boolean Step1Status
            {
                get
                {
                    if (HttpContext.Current.Request.Cookies["Step1"] != null)
                    {
                        return Convert.ToBoolean(HttpContext.Current.Request.Cookies["Step1"].Value);
                    }
                    else
                    {
                        return false;
                    }

                }
                set
                {
                    //Write Cookie &  Timeout
                    HttpCookie StepStatus = new HttpCookie("Step1");
                    StepStatus.Value = value.ToString();                
                    HttpContext.Current.Response.Cookies.Add(StepStatus);
                }
            }
    Then I was going to write an if statement that checks to see if  each of the steps exist and for the ones that do exist, change:
    currentItem.Selected = true;

    How do I get each of the menu items so I can set its selected value to true?

    Also, is this over complicating things or is there a better way to track the pages the user has viewed and change the menu item to a different graphic?

    Thanks for any advice.


  2. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 17 Jan 2011 Link to this post

    Hi Strategon,

    Let me suggest you an easier way to achieve the behaviour that you describe.

    You can obtain the current step value from the query string and mark the corresponding RadMenu item via  HighlightPath method:
    <body>
        <form id="form1" runat="server">
        <div>
        <telerik:RadScriptManager ID="ScriptManager"
            runat="server" />
             
           <telerik:RadMenu ID="RadMenu1" runat="server">
            <Items>
                    <telerik:RadMenuItem Text="Step1"
                        NavigateUrl="MyPage.aspx?Page=Step1">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Step2"
                        NavigateUrl="MyPage.aspx?Page=Step2">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Step3"
                        NavigateUrl="MyPage.aspx?Page=Step3">
                    </telerik:RadMenuItem>
                    </Items>
           </telerik:RadMenu>
            
        </div>
        </form>
    </body>

    protected void Page_Load(object sender, EventArgs e)
    {
        RadMenuItem currentItem = RadMenu1.FindItemByUrl(Request.Url.PathAndQuery);
        if (currentItem != null)
        {
            currentItem.HighlightPath();
        }
        else
            RadMenu1.Items[0].HighlightPath();
    }

    Please find more details about this approach at “Showing the Path to an Item“ help article.

    All the best,
    Kalina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. MissioDei
    MissioDei avatar
    17 posts
    Member since:
    Aug 2008

    Posted 18 Jan 2011 Link to this post

    Kalina,

    Thanks so much for your reply. That is a much better way of accomplishing what I'm trying to do.

    I appreciate the help!

    Derek
Back to Top