What are HTML Helpers?

Started by beingchinmay, 03-25-2017, 03:44:18

Previous topic - Next topic

beingchinmayTopic starter

HTML helpers are methods we can invoke on the Html property of a view. We also have access to URL helpers (via the URL property) and AJAX helpers (via the Ajax property). All these helpers have the same goal, to make views easy to author. The URL helper is also available from within the controller.

Most of the helpers, particularly the HTML helpers, output HTML markup. For example, the BeginForm helper is a helper we can use to build a robust form tag for our search form, but without using lines and lines of code:

@using (Html.BeginForm("Search", "Home", FormMethod.Get)) { <input type="text" name="q" /> <input type="submit" value="Search" /> }


michral86

HTML Helper is just a method that returns a HTML string. The string can represent any type of content that you want.

For example, you can use HTML Helpers to render standard HTML tags like HTML <input>, <button> and <img> tags etc.

You can also create your own HTML Helpers to render more complex content such as a menu strip or an HTML table for displaying database data.

There are three types of HTML helpers as given below:
1. Inline Html Helpers
2. Built-In Html Helpers
3. Standard Html Helpers


richardmsmith

It is nothing but the method that returns the HTML string, in that any type of content like HTML <input>, <button> and <img> tags etc.