ASP.NET MVC > View - Form specific

Text box in ASP.NET MVC view in ASP.NET MVC

How to create a text box in the ASP.NET MVC view?


To create a textbox, use @Html.TextBox helper method. 

@Html.TextBox("FirstName", "Value Optional") 

If the view is using Model and we need to create a textbox corresponding to the Model property, we can use @Html.TextBoxFor helper method

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

Or 

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

The difference between @Html.TextBoxFor and @Html.EditorFor are following 

Taken from http://www.dotnetfunda.com/interviews/show/8702/what-is-the-difference-between-htmleditorforand-htmltextboxfor-in-asp 

 Views: 22491 | Post Order: 27



Write for us






Hosting Recommendations