Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lars Mortensen 90 posts 98 karma points
    Feb 07, 2013 @ 09:24
    Lars Mortensen
    0

    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

  • Lars Mortensen 90 posts 98 karma points
    Feb 07, 2013 @ 09:31
    Lars Mortensen
    0

    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
       
      }
     }
     
    }

  • Charles Afford 1163 posts 1709 karma points
    Feb 11, 2013 @ 22:35
    Charles Afford
    0

    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 :)

  • Funka! 398 posts 661 karma points
    Feb 12, 2013 @ 00:21
    Funka!
    100

    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!

  • Lars Mortensen 90 posts 98 karma points
    Feb 12, 2013 @ 01:32
    Lars Mortensen
    0

    Thanks Funka, Small adjustment big changes :)

Please Sign in or register to post replies

Write your reply to:

Draft