Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

I am making a project in Asp.net MVC using Entity framework and i am confused
C#
Which is better to use Html helper class or simple html control in MVC?


For eg- For Textbox- I can use html helper class and simple html input textbox also.

Please suggest me which one to use and why?

What I have tried:

C#
Hello Sir,

I am making a project in Asp.net MVC using Entity framework and i am confused <pre lang="C#">Which is better to use Html helper class or simple html control in MVC?</pre>

For eg- For Textbox- I can use html helper class and simple html input textbox also.

Please suggest me which one to use and why?
Posted
Updated 16-Dec-16 9:09am
Comments
ZurdoDev 16-Dec-16 13:53pm    
Use the control.

1 solution

The answer depends upon many factors, but just a rule of thumb can be,

If your data in Models requires or has some attributes defined for data validation in the forms, or the data has some special format to follow, then using HTML helpers can help in generating the dynamic UI easily. That is because ASP.NET knows what are the rules to follow in order to write the data.

If you are not having a model validated with attributes, then you should consider using HTML elements and validate their data, format the data using JavaScript (or one of its libraries, jQuery, Angular etc.). I personally use HTML elements more, and I never use HTML helpers at all. Helpers require a lot of backend modification in order to achieve same results on the page.
 
Share this answer
 
Comments
Adityakumar2318 17-Dec-16 10:03am    
Thank you sir. I understood. Accepted your answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900