I have a recursive model like this:
public class Node
{
public int Id { get; set; }
public string Text { get; set; }
public IList Chi
You could use editor templates which respect the current navigational context instead of such @helper.
So define a custom editor template for the Node type ( ~/Views/Shared/EditorTemplates/Node.cshtml):
@model Node
<li>
@Html.LabelFor(x => x.Text)
@Html.EditorFor(x => x.Text)
@if (Model.Childs.Any())
{
<ul>
@Html.EditorFor(x => x.Childs)
</ul>
}
</li>
and then inside some main view:
@model MyViewModel
<ul>
@Html.EditorFor(x => x.Menu)
</ul>
where the Menu property is obviously of type Node.