Quick View of ASP.NET MVC 3 Razor View Engine

转载:http://techbrij.com/565/quick-view-of-asp-net-mvc-3-razor-view-engine

 

File Extension
.cshtml for c# and vbhtml for vb.net

_(underscore)
Files that cannot be shown by direct requests (master pages, partial views etc) have underscore (_) prefix in their names. e.g. _Layout.cshtml

@
start of a server side code block. It doesn’t require you to explicitly close the code-block. (short-hand of <%= %>)

@{ code }
(Multi-line Statements) add multiple lines of server side code by wrapping it within a @{ code } block.

@( )
(Multi-Token Statements) enables a code block to have multiple tokens

@:
to explicitly indicate the start of content in the line

<text>
to render multi-line content blocks

layout page
asp.net master page is recognized in MVC

Layout <file>
layout we want to use within a ASP.NET MVC

@* comment *@
To define server side comment (like <%– –%>) )

@RenderBody
used in layout where we want the views based on this layout to “fill in” specific body content for a requested URL.

@RenderSection
define two sections within our layout that the view templates within our site can optionally choose to fill-in

@section { }
To define section

@model<StrongModelType>
define strongly-typed models

@ViewBag.<myData>
New Dynamic Controller property, It internally stores the property name/value pairs within the ViewData dictionary. It is used to pass Data Between a Controller and a View

@tempdata
To pass State Between Action Methods

Standard HTML Helpers(not a complete list)

* Html.ActionLink()
* Html.BeginForm()
* Html.CheckBox()
* Html.DropDownList()
* Html.EndForm()
* Html.Hidden()
* Html.ListBox()
* Html.Password()
* Html.RadioButton()
* Html.TextArea()
* Html.TextBox()

Other Helpers
Chart,
Crypto,
WebGrid,
WebImage,
WebMail, etc.

转载于:https://www.cnblogs.com/yougyoum/archive/2012/09/14/2685002.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值