Menus still expanded on next visit to site

2 posts, 0 answers
  1. Clive Hoggar
    Clive Hoggar avatar
    334 posts
    Member since:
    Nov 2008

    Posted 13 Jan 2012 Link to this post

    HI

    I have tried several of the ideas in this forum but have not managed to make them work for my case.

    I have a panel bar with sub menus, and the cookie is set to retain the sub menu open when navigating to the 
    pages in the menu.

    What is also happening - that I don't want to happen - is that when the visitor closes their browser and then comes back to the site later, the menu is still at the state it was when they left . ie if there was a sub menu open, it is still open.

    What I have been trying to do (in the panel bar load event) is detect whether there is null referrer (visiting from a bookmark) or the referrer is not a page on the site, and then clear cookies and close all items

    If Request.UrlReferrer IsNot Nothing Then
                    strReferrer = Request.UrlReferrer.GetLeftPart(UriPartial.Authority).ToString()
                    If   InStr(strReferrer, "scargillmovement") > 0 Then
                        ' internal referrer  do not remove cookie
                    Else
                        'external referrer so close menu
                        If Page.Request.Cookies("TelerikRadPanelBarCookie") IsNot Nothing Then
                        Page.Request.Cookies("TelerikRadPanelBarCookie").Value = Nothing
                        End If
     
                        For Each item As RadPanelItem In RadPanelBar1.GetAllItems()
                            If Not item.Items.Count = 0 Then
                                item.Expanded = False
                            End If
                        Next
     
                    End If
                Else
                    ' link straight in from bookmark or type in so remove cookie and close menu
                          If Page.Request.Cookies("TelerikRadPanelBarCookie") IsNot Nothing Then
                           Page.Request.Cookies("TelerikRadPanelBarCookie").Value = Nothing
                           End If
     
                         For Each item As RadPanelItem In RadPanelBar1.GetAllItems()
                                If Not item.Items.Count = 0 Then
                                   item.Expanded = False
                                End If
                          Next
                End If

    Maybe the referrer information is not even available in this page event.   Maybe it can be done in JavaScript after page load?

    Thanks

    Clive


  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 18 Jan 2012 Link to this post

    Hello Clive,

    You can expand/collapse the RadPanelItems using client-side after the page is loaded. Here you can find information how you can achieve that. On the other hand you could try to change the moment when you clear the cookie.

    Greetings,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top