I feel like I’m missing something obvious here. I just wanted to try putting out some simple XML output onto a screen, so I have my model bringing in an xml file to the view as an XElement in a simple mvc3 app. The problem is that none of the html from the helper method is being generated. If I try to render the same elements in the regular foreach loop code it works fine, but it’s almost as though it’s completely skipping over the helper, or just not caring enough to render the element.
Is there something simple I’m missing?
@helper NavigateElement(XElement xElement)
{
if (xElement.HasElements)
{
foreach (XElement xChildElement in xElement.Elements())
{
NavigateElement(xChildElement);
}
}
else
{
@Html.Label(xElement.Name.LocalName.ToString())
@Html.TextBox(xElement.Name.ToString(), xElement.Value)
}
}
@foreach (XElement xElement in Model.exampleXML.Elements())
{
if (xElement.HasElements)
{
foreach (XElement xChildElement in xElement.Elements())
{
NavigateElement(xChildElement);
}
}
else
{
@Html.Label(xElement.Name.LocalName.ToString())
@Html.TextBox(xElement.Name.ToString(), xElement.Value)
}
}
Do you actually call your helper anywhere?