1.

What are HTML Helpers in MVC

Answer»

Like in ASP.Net web forms, we have a toolbox for adding controls (like textbox, label, dropdown) on any particular page. Now, in the ASP.NET MVC application, there is no toolbox available to add controls on the view. ASP.NET MVC provides HtmlHelper class which contains various methods that help you create HTML controls programmatically. All HtmlHelper methods generate HTML and return the RESULT as a STRING. The final HTML is generated at runtime by these FUNCTIONS. The HtmlHelper class is designed to generate UI and it should not be used in controllers or models.

The following is the list of Html Helper controls.

Html.Beginform

Html.EndForm

Html.Label

Html.TextBox

Html.TextArea

Html.Password

Html.DropDownList

Html.CheckBox

Html.RedioButton

Html.ListBox

Html.Hidden

Below are Strongly TYPE Html Helper methods, this will allow us to check compile-time errors. 

We get Model's Property intelligence at Runtime.

Html.LabelFor

Html.TextBoxFor

Html.TextAreaFor

Html.DropDownListFor

Html.CheckBoxFor

Html.RadioButtonFor

Html.ListBoxFor

Html.HiddenFor

HtmlHelper class generates html elements. For example, @Html.ActionLink("Create New", "Create") would generate anchor tag <a href="/Student/Create"&GT;Create New</a>.



Discussion

No Comment Found