Copied to clipboard

Flag this post as spam?

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


  • Lars Ljungqvist 14 posts 34 karma points
    Jan 17, 2013 @ 14:09
    Lars Ljungqvist
    0

    Razor will not put a character before

    Hi

    I have a simple razor script in Umbraco for a menu. I want to put an asterix in front of the links:

    <ul>
       
    @foreach (var page in Model.AncestorOrSelf(2).Children)
    {
       <li>*<a href="@page.Url" title="@page.Name"> @page.Name</a></li>
    }
    </ul>

    However, it renders like this putting the first asterix behind the link and not before:

    First link *
    * Second link

    Anyone knows how to put the asterix in front of the link every time. Eventually by the attribute "InstertBefore", but any small trick will do :-)

    Thank you in advance for any help.

    Lars

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 17, 2013 @ 14:11
    Fuji Kusaka
    0
    <li> <a href="@page.Url" title="@page.Name"> @:* @page.Name</a></li>
  • Lars Ljungqvist 14 posts 34 karma points
    Jan 18, 2013 @ 09:37
    Lars Ljungqvist
    0

    Hi Fuji

    Thank you for your answer. However I can still not make it work. When I save the code Umbraco returns an error:

    "Error occured":" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid."

    Do you know how to fix that error.

    Regards,
    Lars

  • Niels Jorck Ellegaard 39 posts 245 karma points
    Jan 22, 2013 @ 10:03
    Niels Jorck Ellegaard
    0

    Your first solution should actually work fine, I just tested myself.

    I believe you might have some CSS that is moving it around a bit funny.

    If you dont mind the asterix to be a part of the link you could do this:

    <ul>
    @foreach (var page in Model.AncestorOrSelf(2).Children)
    {
       
    <li><ahref="@page.Url"title="@page.Name">* @page.Name</a></li>
    }
    </ul>

    That should work, even with some funky CSS.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 23, 2013 @ 05:29
    Fuji Kusaka
    0

    Did you get this working ?

Please Sign in or register to post replies

Write your reply to:

Draft