开发者

Razor view engine, how to write inbetween html?

开发者 https://www.devze.com 2023-02-09 09:12 出处:网络
i have some problem with a razor syntax. I would like to know ho开发者_开发问答w to write inbetween html.. see this sample..

i have some problem with a razor syntax. I would like to know ho开发者_开发问答w to write inbetween html.. see this sample..

<ul>
    @foreach (var x in Model) {
        <li>
            @x.Subject - Tags:&nbsp;

            @if (x.Tags != null)
            {

                foreach (var t in x.Tags)
                {
                    @t.Name
                }
            }
            else
            { 
                No tags
            }
        </li>
    }
</ul>

I should be able to write "No Tags" but this doesnt work... No tags seem included in the code (which is not what i want.

Thanks


You need to explicitly tell Razor that you're writing HTML, by writing @:No Tags or <text>No Tags</text>.


Does using the <text> tag work? For example:

<text>No tags</text>
0

精彩评论

暂无评论...
验证码 换一张
取 消