开发者

MvcContrib MenuBuilder with Razor view engine

The below code (inside a .cshtml file) causes the menu to render outside of the flow of the document i.e. The first lines in the source above the html tag

@{
    Html.Menu(
        Menu.Beg开发者_如何转开发in(new[]
                        {
                            Menu.Link(Url.Action("action1", new { controller="controller" }), "Action1"),
                            Menu.Link(Url.Action("action2", new { controller="controller" }), "Action2")
                        }));
}

Yet in a webforms project, the following works:

<% Html.Menu(
        Menu.Begin(new[]
                        {
                            Menu.Link(Url.Action("action1", new { controller="controller" }), "Action1"),
                            Menu.Link(Url.Action("action2", new { controller="controller" }), "Action2")
                        })); %>

I believe the two syntaxes should result in the same outcome.


@Html.Menu(
        Menu.Begin(new[]
                        {
                            Menu.Link(Url.Action("action1", new { controller="controller" }), "Action1"),
                            Menu.Link(Url.Action("action2", new { controller="controller" }), "Action2")
                        }))

That should work.. Removing the braces {}


You should think of @( ) being the equivalent of <%= %> rather than @{ } when converting to razor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜