ASP.NET MVC3 C# Razor 语法
来源:互联网 发布:优化系统设置的目的 编辑:程序博客网 时间:2024/04/30 06:37
简明版
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
@{ int x = 123; string y = "because.";}
<% int x = 123; string y = "because."; %>Expression (Html Encoded)
<span>@model.Message</span>
<span><%: model.Message %></span>Expression (Unencoded)
<span>@Html.Raw(model.Message)</span>
<span><%= model.Message %></span>Combining Text and markup
@foreach(var item in items) { <span>@item.Prop</span> }
<% foreach(var item in items) { %> <span><%: item.Prop %></span><% } %>Mixing code and Plain text
@if (foo) { <text>Plain Text</text> }
<% if (foo) { %> Plain Text <% } %>Mixing code and plain text (alternate)
@if (foo) { @:Plain Text is @bar}Same as above Email Addresses
Hi philha@example.comRazor recognizes basic email format and is smart enough not to treat the @ as a code delimiter Explicit Expression
<span>ISBN@(isbnNumber)</span>In this case, we need to be explicit about the expression by using parentheses. Escaping the @ sign
<span>In Razor, you use the @@foo to display the value of foo</span>@@ renders a single @ in the response. Server side Comment
@*This is a server side multiline comment *@
<%--This is a server side multiline comment--%>Calling generic method
@(MyClass.MyMethod<AType>())Use parentheses to be explicit about what the expression is. Creating a Razor Delegate
@{ Func<dynamic, object> b = @<strong>@item</strong>;}@b("Bold this")Generates a Func<T, HelperResult> that you can call from within Razor. See this blog post for more details. Mixing expressions and text
Hello @title. @name.
Hello <%: title %>. <%: name %>.
详细版
http://www.asp.net/webmatrix/tutorials/2-introduction-to-asp-net-web-programming-using-the-razor-syntax
- ASP.NET MVC3 C# Razor 语法
- ASP.NET MVC3 Razor 语法
- Asp.net MVC3 Razor语法
- ASP.NET MVC3 Razor语法简介
- ASP.NET MVC3的Razor语法
- ASP.NET MVC3细嚼慢咽---(3)Razor视图语法
- ASP.NET MVC3 系列教程 - Razor视图引擎基础语法
- ASP.NET MVC3 Razor视图引擎-基础语法
- ASP.NET MVC3 Razor视图引擎的语法
- ASP.NET MVC3 Razor视图引擎-基础语法
- ASP.NET MVC3 Razor布局
- asp.net mvc3 razor简介
- ASP.NET Razor语法
- ASP.NET MVC3: Razor中的布局
- ASP.NET MVC3: Razor 中的布局
- ASP.NET Razor - C#
- ASP.NET Razor – C# 和 VB 代码语法
- ASP.NET MVC Razor语法
- vi
- 看到一首喜欢的诗,转载如下: 你见,或者不见我 我就在那里
- Summary of Operators
- JBuilder ,Myeclipse调试外部项目
- jboss 不能载入自定义类的问题
- ASP.NET MVC3 C# Razor 语法
- TD容量计算
- Oracle中打开10046 Trace的各种方法
- android handlerthread 通知机制
- 使用SQL_TRACE进行数据库诊断
- ASIHTTPRequest
- myeclipse这个是什么意思?
- 贝塔中的DBA
- skia的 jni接口