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

[Solved] Dynamically adding to site map at runtime

1 Answer 17 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff
Top achievements
Rank 1
Jeff asked on 16 Dec 2011, 04:08 PM
In our enivronment, we have static XML sitemaps for our standard product. I am trying to integrate a third party solution, and add items to certain menus at runtime based on the result of a Web service call to the third party.  I would really like to not put the code in the razor view, if possible.  Here is what we have:

@(Html.Telerik().Menu()
    .Name("SiteMasterTopMenu")
        .BindTo("SiteMasterTopMenu_" +
                (!string.IsNullOrEmpty((string)ViewBag.LoginType) ?
                    ViewBag.LoginType : 
                    "Employee")
            )
    .HtmlAttributes(new { @class = "smtopmenu" }))

I realize that I will need to somehow insert something inside the .BindTo() method. I'm just not sure, since this particular partial view is generic.  Do I need to make it strongly typed and have a method that looks up the information and creates it behind the scenes?

Thanks in advance,
Jeff

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 20 Dec 2011, 08:58 AM
Hello Jeff,

 
In order to achieve your goal you will need to prepare the list of SiteMapNode objects in a advance. Then you can pass the list to the view, either as a Model (strongly-typed) or through ViewData. Then you can use the BindTo method which accepts a list of objects. Check this online demo which shows how to use it. If the problem still persists I will ask you a test project, which shows current implementation.

Regards,
Georgi Krustev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Menu
Asked by
Jeff
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or