RadSiteMap and Dynamic RadMenu

7 posts, 0 answers
  1. Michele
    Michele avatar
    29 posts
    Member since:
    Jun 2011

    Posted 22 Jul 2013 Link to this post

    Hi, I have a web page that inside it has a user control where I put RadSiteMap. This user control charge inside another user control that has a radmenu dynamically loaded from sqldatasource.
    In the page load event of the user control where I put RadSiteMap I included this
             Try
                 Dim UC_text As UserControl = DirectCast (Me.FindControl ("MenuOr1"), UserControl)
                 Dim RMenu As RadMenu = CType (UC_text.FindControl ("RadMenu1"), RadMenu)
                 Dim CurrentItem As RadMenuItem = RMenu.FindItemByUrl (Request.Url.PathAndQuery)
                 If CurrentItem IsNot Nothing Then
                     'Select the current item and his parents
                     currentItem.HighlightPath ()
                     'Update the title of the
                     PageTitleLiteral.Text = currentItem.Text
                     'Populate the breadcrumb
                     DataBindBreadCrumbSiteMap (CurrentItem)
                 else
                     RMenu.Items (0). HighlightPath ()
                 end If

             Catch ex As Exception

             end Try

    As this function Dim CurrentItem RadMenuItem = RMenu.FindItemByUrl (Request.Url.PathAndQuery)

    no value.
    Can you help?
    thanks
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 25 Jul 2013 Link to this post

    Hello,

    Could you please try to use the following code implementation in order to return the RadMenuItem instead of null.
    //markup code
    <telerik:RadMenu ID="RadMenu1" runat="server">
        <Items>
            <telerik:RadMenuItem Text="Item1" NavigateUrl="http://localhost:50920/Menu/SamplePage.aspx?Item1"></telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Item2" NavigateUrl="http://localhost:50920/Menu/SamplePage.aspx?Item2"></telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Item3" NavigateUrl="http://localhost:50920/Menu/SamplePage.aspx?Item3"></telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>

    //code behind
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            Try
                Dim UC_text As UserControl = DirectCast(Me.FindControl("MenuOr1"), UserControl)
                Dim RMenu As RadMenu = CType(UC_text.FindControl("RadMenu1"), RadMenu)
                Dim CurrentItem As RadMenuItem = RMenu.FindItemByUrl(Request.Url.ToString())
                If CurrentItem IsNot Nothing Then
                    'Select the current item and his parents
                    CurrentItem.HighlightPath()
                    'Update the title of the
                    PageTitleLiteral.Text = CurrentItem.Text
                    'Populate the breadcrumb
                    DataBindBreadCrumbSiteMap(CurrentItem)
                Else
                    RMenu.Items(0).HighlightPath()
                End If
     
            Catch ex As Exception
     
            End Try
        End Sub

    I would like to clarify that the navigate URL host "localhost" is set for sample purposes. 

    Regards,
    Boyan Dimitrov
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michele
    Michele avatar
    29 posts
    Member since:
    Jun 2011

    Posted 25 Jul 2013 Link to this post

    thanks I solved the problem by calling the databind the menu before calling the function in question
  5. Michele
    Michele avatar
    29 posts
    Member since:
    Jun 2011

    Posted 25 Jul 2013 Link to this post

    I have another problem, I would like to change the font color dynamically:

    <telerik:RadSiteMap ID="BreadCrumbSiteMap" runat="server" DataTextField="Text"

    DataNavigateUrlField="NavigateUrl">

    <DefaultLevelSettings ListLayout-RepeatDirection="Horizontal" SeparatorText="/" Layout="Flow" />

    </telerik:RadSiteMap

     

     

     

     

     

    >

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

         BreadCrumbSiteMap.Style.Add("color", "#000000")
    End Sub

     not  Work
    how can I do?
  6. Michele
    Michele avatar
    29 posts
    Member since:
    Jun 2011

    Posted 29 Jul 2013 Link to this post

    no solution?
  7. Michele
    Michele avatar
    29 posts
    Member since:
    Jun 2011

    Posted 29 Jul 2013 Link to this post

    how do I convert this post to a ticket
    thanks
    Michele
  8. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 30 Jul 2013 Link to this post

    Hello,

    I would like to clarify that Kate have already answered to "change the font color dynamically" question in the support thread with id 720859 and form thread with id 720851. Please review the answers and continue the communication in the aforementioned threads.
    I would like to note that in order to avoid any further confusions please use the RadMenu forum section for questions and issues regarding RadMenu control.

    Thank you for understanding.

    Regards,
    Boyan Dimitrov
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017