简体   繁体   中英

Html.ActionLink in Html.TreeView?

Hi,

Im using the HTML.TreeView to render my code structure like this :

            <%= Html.TreeView("CategoryTree",
            Model.CategoryList,
            l => l.ChildList,
            l => l.Name + "&nbsp;/&nbsp;<a id=\"treeLnk" + l.Id + "\" href=\"JavaScript: OpenAddDialog('" + l.Name + "', " + l.Id + ") \" title=\"Lägg till\" >Lägg till</a>" +
                          "&nbsp;/&nbsp;<a id=\"treeLnk" + l.Id + "\" href=\"JavaScript: OpenChangeNameDialog('" + l.Name + "', " + l.Id + ") \" title=\"Ändra namn\" >Ändra namn</a>" +
                          "&nbsp;/&nbsp;<a id=\"treeLnk" + l.Id + "\" href=\"JavaScript: OpenDeleteDialog('" + l.Name + "', " + l.Id + ") \" title=\"Tabort\" >Tabort</a>") %>

This work fine, but now I need to include a action that redirects to another controller\\action.

I have tried to ad a Html.ActionLink but this does not work?

You could have specified which TreeView helper are you using because there's no such thing built-in ASP.NET MVC but try like this:

<%= Html.TreeView("CategoryTree",
    Model.CategoryList,
    l => l.ChildList,
    l => l.Name + Html.ActionLink("Link Text", "action", "controller").ToHtmlString()) 
%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM