Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As soon as you start tag in Razor, it switches to markup (including <code>&lt;script&gt;</code>). If you don't need any tag, use <code>&lt;text&gt;</code> instead.</p> <p>If you need quick copy/paste solution, take Tim's or Adam's as both do the job. However, as Razor uses pretty complex algorithms while parsing mix of several languages, it is worth providing <a href="http://haacked.com" rel="nofollow">Phil Haack</a>'s <a href="http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx" rel="nofollow">Razor part of quick reference</a> in its entirety (allowed by CC-BY license):</p> <blockquote> <p>Code Block:</p> <pre><code>@{ int x = 123; string y = "because."; } </code></pre> <p>Expression (Html Encoded):</p> <pre><code>&lt;span&gt;@model.Message&lt;/span&gt; </code></pre> <p>Expression (Unencoded):</p> <pre><code>&lt;span&gt; @Html.Raw(model.Message) &lt;/span&gt; </code></pre> <p>Combining Text and markup:</p> <pre><code>@foreach(var item in items) { &lt;span&gt;@item.Prop&lt;/span&gt; } </code></pre> <p>Mixing code and Plain text:</p> <pre><code>@if (foo) { &lt;text&gt;Plain Text&lt;/text&gt; } </code></pre> <p>Mixing code and plain text (alternate):</p> <pre><code>@if (foo) { @:Plain Text is @bar } </code></pre> <p>Email Addresses:</p> <pre><code>Hi philha@example.com </code></pre> <p>Explicit Expression:</p> <pre><code>&lt;span&gt;ISBN@(isbnNumber)&lt;/span&gt; </code></pre> <p>Escaping the @ sign:</p> <pre><code>&lt;span&gt;In Razor, you use the @@foo to display the value of foo&lt;/span&gt; </code></pre> <p>Server side Comment:</p> <pre><code>@* This is a server side multiline comment *@ </code></pre> <p>Calling generic method:</p> <pre><code>@(MyClass.MyMethod&lt;AType&gt;()) </code></pre> <p>Mixing expressions and text:</p> <pre><code>Hello @title. @name. </code></pre> </blockquote> <p>I left out Razor delegate since there are <a href="http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx" rel="nofollow">Razor helpers</a> now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload