Ajax3.14
Ajax3.14

Reputation: 1695

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

I am working in asp.net application, adding functionalities like form elements, validation and populating data from DB.

  1. I can use ASP: controls but I am wondering is it possible to use HTML.TextBox or <input type="text">

  2. If I can use <input type="text" or Html.TextBox what are the pros and cons of using them versus using

Upvotes: 3

Views: 4531

Answers (2)

Tejs
Tejs

Reputation: 41266

If you're using ASP.NET MVC, then either the manual typing (<input type="text" />) or the helper extension (Html.TextBoxFor(x => x.SomeProperty)) are going to be your best bet, and it really depends on what you are planning on doing. If the control you are making has no property on your element, it can be a lot easier to simply hand code the input tag.

Never use <asp:Checkbox ID="blah" runat="server" /> in an MVC application.

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1039488

Forget about server side controls in ASP.NET MVC. Everything containing runat="server" is a big NO in ASP.NET MVC. Won't work in Razor anyways. There are no pros and cons. Server side controls should never be used so there's nothing to compare. Simply use HTML helpers such as Html.EditorFor and Html.TextBoxFor.

Upvotes: 4

Related Questions