簡明版
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
Syntax/Sample | Razor | Web Forms Equivalent (or remarks) |
---|---|---|
Code Block | | |
Expression (Html Encoded) | ||
Expression (Unencoded) | | |
Combining Text and markup | | |
Mixing code and Plain text | | |
Mixing code and plain text (alternate) | | Same as above |
Email Addresses | | Razor recognizes basic email format and is smart enough not to treat the @ as a code delimiter |
Explicit Expression | In this case, we need to be explicit about the expression by using parentheses. | |
Escaping the @ sign | | @@ renders a single @ in the response. |
Server side Comment | | |
Calling generic method | Use parentheses to be explicit about what the expression is. | |
Creating a Razor Delegate | | Generates a Func<T, HelperResult> that you can call from within Razor. See this blog post for more details. |
Mixing expressions and text | | |
詳細版
http://www.asp.net/webmatrix/tutorials/2-introduction-to-asp-net-web-programming-using-the-razor-syntax