3

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

tereško
58.5k26 gold badges100 silver badges151 bronze badges
asked May 1, 2012 at 17:31

2 Answers 2

4

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.

answered May 1, 2012 at 17:33
Sign up to request clarification or add additional context in comments.

2 Comments

my application is asp.net and guess it not MVC... So Razor is not recognised right.. moreover can you please elaborate the strong statement you made "server side controls should not be used"
@Ajax3.14, server side controls rely on events, postbacks and view state. Those are notions that no longer exist in ASP.NET MVC. They have been replaced by html helpers. So if you are developing an ASP.NET MVC application you should use HTML helpers.
3

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.

answered May 1, 2012 at 17:34

2 Comments

my application is just asp.net so you think your answer is still applicable in asp.net..can i use (Html.TextBoxFor(x => x.SomeProperty))
If it's traditional WebForms, then do completely the reverse.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.