This is a migrated thread and some comments may be shown as answers.

Menus still expanded on next visit to site

1 Answer 38 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 13 Jan 2012, 09:06 PM
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


1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 18 Jan 2012, 02:38 PM
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
Tags
PanelBar
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or