1. What is HTML Helper Class in ASP.NET MVC?
2. What is the difference between HTML Helper Class and simple HTML Controls?
3. How to bind HTML Helper Control to a models
What is HTML Helper Class in ASP.NET MVC?
As you know already that MVC doesn't use Server Control and instead it uses plain HTML Control. The benefit of using plain HTML control is; it loads faster and easily readable. However, plain HTML controls don’t get strongly bounded with models and in this situation, HTML Helper class helps a lot.
HTML Helper Class have set of methods that later converted into plain HTML Controls. The benefit of using HTML Helper class is that the HTML controls get rendered correctly and checked at compile time. So, if there is any problem with control, it can be corrected before running the final project.Example: Standard HTML Helper
The HTML Helper
@Html.TextBox("Textbox1", "val")will render the following html control.
<input id="Textbox1" name="Textbox1" type="text" value="val" />
However, it is not strongly bounded with models and generate plain HTML text box. For strongly type HTML control, we will use the following method.Strongly Typed HTML Helper
<input id="Name" name="Name" type="text" value="Name-val" />
This textbox is strongly bounded with Name properties of models m.
This is just a demo that shows you the structure of HTML Helper class. In the next few chapters, you will study all the method of HTML Helper class with complete programming example.
Here, is the list of HTML Helper MethodHtml.Label
This is a very basic chapter, which only introduces you to HTML Helper Class. In the next few chapters, you will learn how to use different types of HTML Helper method with programming example.