Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 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 4861 posts 12138 karma points MVP 3x admin c-trib
    Nov 26, 2014 @ 12:05
    Jeroen Breuer
    102

    Try this:

    <text> - </text>

    Jeroen

  • Claushingebjerg 886 posts 2415 karma points
    Nov 26, 2014 @ 12:07
    Claushingebjerg
    0

    Perfect :)

  • Dennis Aaen 4457 posts 17970 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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies