ASP.NET Core 1.0.1 Hosting: Advantages Of Razor Syntax And Difference Between @Html.Editorfor And @Html.TextBoxFor

First of all, we will look into some of the main advantages of use of Razor syntax.

  • It is light weight and it has a simple syntax.
  • It is easier to understand Razor syntax as compared to ASPX view engine syntax.
  • Provides automatic encoding of HTML output.
  • Razor syntax code is more succinct.
  • Provides great readability of markup and code.

Let us see the difference between @Html.Editorfor and @Html.TextBoxFor in Razor syntax ASP.NET MVC.
Code snippet for MVC model
The MODEL in MVC app is given below.

Now, let us see the actual difference.
Razor syntax code snippet for Html.EditorFor

For the line given above, it renders a textbox for UserName model property.

For the line given above, it renders a checkbox control for IsActive model property, since model property is a kind of Boolean result.
Razor syntax code snippet for Html.TextBoxFor,

In this, it renders the textbox control for both UserName and IsActive model properties.