Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 937 posts 2572 karma points
    Nov 26, 2014 @ 12:02
    Claushingebjerg
    0

    syntax, html inside razor block

    I have a thing thtas been bugging me for a while, and im sure the answer is very simple.

    <p>
    <a href="@page.Url">
    <strong>Kl. @page.dato.ToString("HH:mm")
        @if(@page.HasValue("evtSluttidspunkt")){
         &nbsp;-&nbsp;@page.evtSluttidspunkt
        }
    </a>
    </p>

    Fails because of the html before the razor inside the if

    <p>
    <a href="@page.Url">
    <strong>Kl. @page.dato.ToString("HH:mm")
        @if(@page.HasValue("evtSluttidspunkt")){
         @page.evtSluttidspunkt
        }
    </a>
    </p>

    works fine.

    How do i get the "&nbsp;-&nbsp;" rendered?

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 26, 2014 @ 12:05
    Jeroen Breuer
    102

    Try this:

    <text> - </text>

    Jeroen

  • Claushingebjerg 937 posts 2572 karma points
    Nov 26, 2014 @ 12:07
    Claushingebjerg
    0

    Perfect :)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 26, 2014 @ 12:34
    Dennis Aaen
    1

    Hi Claus and Jeroen,

    I konw that I am a little bit late here.

    Razor’s @: and <text></text> syntax can then be used for scenarios where you want to avoid using an HTML element within a code container block.

    So you could also do:

    @:-

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft