The "[email protected](ulClass)" element was not closed. All elements must be either self-closing or have a matching end tag
Hi Just upgraded my umbraco from newest V4 to V6.I have the following code in a "Scripting File"[code]@inherits umbraco.MacroEngines.DynamicNodeContext@{ var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass); var ulID = String.IsNullOrEmpty(Parameter.ulID) ? "" : String.Format(" id=\"{0}\"", Parameter.ulID); <[email protected](ulClass)@Html.Raw(ulID)> @if(@Model.Children.Any()) { foreach (var item in @Model.Children.Where("Visible")) { var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : ""; <[email protected](selected)> <a href="@item.Url">@item.Name</a> </li> } }else{ foreach (var item in @Model.Parent.Children) { var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : ""; <[email protected](selected)> <a href="@item.Url">@item.Name</a> </li> } } </ul>}[/code]When trying to save it fails with:The "[email protected](ulClass)" element was not closed. All elements must be either self-closing or have a matching end tag. The code worked in V4Can someone help?Regards Lars Mortensen
I guess what is happening is in some case your ulClass and ullD variables are returning "" (empty string) thus the <li> is now self closing /> which will cause an error or you have not closed the <ul> </ul> element.
Try putting a space after the UL, before the @Html... There may be some primitive parsing going on that doesn't recognize the tag is actually UL instead of some tag called UL@Html... (In which case, it would be looking for closing tag of </UL@Html...> maybe?)
P.S., the code you posted on the second try does actually seem to be missing the closing /UL but looks like it is sort of there in your first post. Just FYI. And good luck to you!
The "[email protected](ulClass)" element was not closed. All elements must be either self-closing or have a matching end tag
Hi Just upgraded my umbraco from newest V4 to V6.I have the following code in a "Scripting File"[code]@inherits umbraco.MacroEngines.DynamicNodeContext@{ var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass); var ulID = String.IsNullOrEmpty(Parameter.ulID) ? "" : String.Format(" id=\"{0}\"", Parameter.ulID); <[email protected](ulClass)@Html.Raw(ulID)> @if(@Model.Children.Any()) { foreach (var item in @Model.Children.Where("Visible")) { var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : ""; <[email protected](selected)> <a href="@item.Url">@item.Name</a> </li> } }else{ foreach (var item in @Model.Parent.Children) { var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : ""; <[email protected](selected)> <a href="@item.Url">@item.Name</a> </li> } } </ul>}[/code]When trying to save it fails with:The "[email protected](ulClass)" element was not closed. All elements must be either self-closing or have a matching end tag. The code worked in V4Can someone help?Regards Lars Mortensen
Can't edit my post so I get an XSLT error.
But the code isn't easy se see, so I try again without the code tag. :)
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level);
var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass);
var ulID = String.IsNullOrEmpty(Parameter.ulID) ? "" : String.Format(" id=\"{0}\"", Parameter.ulID);
<[email protected](ulClass)@Html.Raw(ulID)>
@if(@Model.Children.Any())
{
foreach (var item in @Model.Children.Where("Visible")) {
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
<[email protected](selected)>
@item.Name
}
}else{
foreach (var item in @Model.Parent.Children) {
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
<[email protected](selected)>
@item.Name
}
}
}
I guess what is happening is in some case your ulClass and ullD variables are returning "" (empty string) thus the <li> is now self closing /> which will cause an error or you have not closed the <ul> </ul> element.
Hope this helps.
Charlie :)
Try putting a space after the UL, before the @Html... There may be some primitive parsing going on that doesn't recognize the tag is actually UL instead of some tag called UL@Html... (In which case, it would be looking for closing tag of </UL@Html...> maybe?)
For example, <ul @Html.Raw...> instead of <[email protected]...>
P.S., the code you posted on the second try does actually seem to be missing the closing /UL but looks like it is sort of there in your first post. Just FYI. And good luck to you!
Thanks Funka, Small adjustment big changes :)
is working on a reply...