Get Panel Bar in master page

5 posts, 1 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 16 Mar 2011 Link to this post

    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?
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 18 Mar 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 21 Mar 2011 Link to this post

    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>
  5. Answer
    Kate
    Admin
    Kate avatar
    1898 posts

    Posted 24 Mar 2011 Link to this post

    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
  6. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 24 Mar 2011 Link to this post

    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"
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017