Jasinski Technical Wiki


Home Page
All Pages

Quick Search
Advanced Search »

Contributor Links

Create a new Page
File Management
Your Profile

Other Wiki Sections



View Engine (Razor and ASPX) Syntax - ASP.NET MVC

Modified on Tue, Jul 23, 2013, 11:15 AM by Administrator Categorized as ASP·NET MVC
This page is a Draft. Its content is not complete and might contain errors.

ASPX Markup


  • To include a value from the model (or other server-side code), use the <%: xyz %> syntax — with a colon. For example: <%: Model.Descrip %>
  • To start a block of server-side code (for example an if block or for loop, use the <% xyz %> syntax.


<% using (Html.BeginForm("SaveClient", "Admin", FormMethod.Post)) { %>

. . .

<% } %>

Partial Views

<% Html.RenderPartial("Categories"); %>

Razor HTML Helpers

The following are all methods of @Html

  • LabelFor — shows the text in [Display(Name="xyz")] (System.ComponentModel.DataAnnotations)
  • TextBoxFor — with formatted date: @Html.TextBoxFor(m => m.DOB, "{0:MM/dd/yyyy}")
  • HiddenFor
  • ValidationSummary
  • ValidationMessageFor
  • CheckBoxFor
  • TextAreaFor
  • DropDownListFor — e.g., @Html.DropDownListFor(m => m.StateID, new SelectList(Model.States, "ID", "Descrip"))
  • PassswordFor
  • ActionLink
  • Partial
  • Raw

  • DisplayFor — Uses view in /Views/Shared/DisplayTemplates folder. If none found there, shows field value as read-only "label".
  • EditorFor — Uses view in /Views/Shared/EditorTemplates folder.

ScrewTurn Wiki version Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.