What is the difference between Html.EditorFor and Html.TextBoxFor in ASP.NET MVC?

 Posted by Sheonarayan on 7/11/2014 | Category: ASP.NET MVC Interview questions | Views: 41511 | Points: 40


@Html.EditorFor(model => model.LastName)

This HTML helper method is very dynamic in nature. Based on which type of data is passed to this method, the output changes.

For example,
1. if model property type is of string type, it renders a textbox
2. if the property type is boolean type it renders a checkbox.
3. if the property type is of integer type, it render input type="number" textbox.

In order to control the output of the Html.EditorFor we can use EditorTemplates for different data types.


@Html.TextBoxFor(model => model.LastName)

This HTML helper method only renders a TextBox as output irrespective of whatever data type the model property is of.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response