Vs Html.TextBox I work in an asp.net application, adding functions such as form elements, validation an...">

<asp: TextBox> Vs <input type = "text"> Vs Html.TextBox

I work in an asp.net application, adding functions such as form elements, validation and filling in data from the database.

  • I can use ASP: controls, but I'm wondering if you can use HTML.TextBoxeither<input type="text">

  • If I can use <input type="text"or HTML.TextBox, what are the pros and cons of using them compared to using

+3
source share
2 answers

Forget about server-side controls in ASP.NET MVC. Everything that contains runat="server"is a big NO in ASP.NET MVC. In any case, it will not work in Razor. There are no pluses or minuses. Server-side controls should never be used, so there is nothing to compare. Just use HTML helpers like Html.EditorForand Html.TextBoxFor.

+4
source

If you use ASP.NET MVC, then you would be best off using manual text input ( <input type="text" />) or helper extension ( Html.TextBoxFor(x => x.SomeProperty)), and it really depends on what you plan on doing. If the control you create does not have a property for your element, the easiest way is to simply pass in the code for the input tag.

<asp:Checkbox ID="blah" runat="server" /> MVC.

+3

All Articles