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

Get Panel Bar in master page

4 Answers 90 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 16 Mar 2011, 10:09 PM
I have a panel bar in a master page and I have code in my vb of the master page to set the selected link to show like so

Dim clickedItem As RadPanelItem = RadPanelBar1.FindItemByUrl(Request.Url.PathAndQuery)
 
If Not (clickedItem Is Nothing) Then
    clickedItem.ExpandParentItems()
    Dim childItem As RadPanelItem
    For Each childItem In clickedItem.PanelBar.GetAllItems()
        childItem.CssClass = ""
    Next childItem
 
    clickedItem.CssClass = "rpSelected"
 
End If

The problem is, I have some pages you can get to by links within other pages that aren't in the panel bar. I would like to manually set the panel bar on these pages. However, I'm having trouble figuring out how I can get the control because it's in a master page. I've tried something like this 
        Dim clickedItem As RadPanelItem = Master.FindControl("Radmenu1")
        Dim rad As RadPanelItem = clickedItem.FindItemByUrl("Leads/LeadList.aspx")
but I can't seem to figure out how to get the control to set which item. Any ideas?

4 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 18 Mar 2011, 12:06 PM
Hello Web Services,

You can refer to the following article: How to: Reference ASP.NET Master Page Content. It explains how you can achieve this.

Best wishes,
Kate
the Telerik team
0
Web Services
Top achievements
Rank 2
answered on 21 Mar 2011, 07:37 PM
So I may be closer, but I can't seem to figure out how to get the rad panel item. Here is my vb
Dim clickedItem As RadPanelItem = Master.FindControl("RadPanelBar1")
            clickedItem.FindControl("jobsList")

Here is what the item looks like in the master page
<telerik:RadPanelBar runat="server" ID="RadPanelBar1" ExpandMode="FullExpandedItem"
                           Height="100%">
                           <Items>
                               <telerik:RadPanelItem Text="Jobs">
                                   <Items>
                                       <telerik:RadPanelItem Text="Jobs List" id="jobsList" NavigateUrl="~/Jobs/JobsList.aspx" />
                                   </Items>
                               </telerik:RadPanelItem>
                           </Items>
                       </telerik:RadPanelBar>
0
Accepted
Kate
Telerik team
answered on 24 Mar 2011, 10:31 AM
Hi Web Services,

To get an item of the RadPanelBar you will first need to get the panel bar itself. The code of the master page that you sent looks good but for the code behind you can try the following approach:
Dim panelBar As RadPanelBar = Master.FindControl("RadPanelBar1")
Dim selectedItem As RadPanelItem = panelBar.SelectedItem

Regards,
Kate
the Telerik team
0
Web Services
Top achievements
Rank 2
answered on 24 Mar 2011, 03:03 PM
Ah. Thanks for the help. Here's what I ended up with in case anyone else needs it.
'get the panel bar by it's id
Dim panelBar As RadPanelBar = Master.FindControl("RadPanelBar1")
 
'this is the text in the panel bar that you want expanded
Dim selectedItem As RadPanelItem = panelBar.FindItemByText("Jobs")
 
'set it to expanded
selectedItem.Expanded = True
 
'get the items within the panel bar starting at 0
'this is the second item in the panel bar
'set the class to selected
selectedItem.Items(1).CssClass = "rpSelected"
Tags
PanelBar
Asked by
Web Services
Top achievements
Rank 2
Answers by
Kate
Telerik team
Web Services
Top achievements
Rank 2
Share this question
or