Close

BLOGS

HTML helper in ASP.NET MVC - An Overview

What is HTML helper?

 

An HTML helper is a method that is used to render html content in a view. HTML helpers are implemented as extension methods. 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.

<input type="text" name="firstname" id="firstname"/>


The above HTML line produce the HTML for a textbox with id="firstname" and name="firstname". The similar code using using HTML helper is as follows:

 

@Html.TextBox("firstname")

If we see the page source in browser it will generate the same html code as shown in the following screen

The same with its overloaded version are for example with value and name as follows:

@Html.TextBox("firstname", "Smith")


Its not mandatory to use HTML helper in ASP.NET MVC but using HTML helper will greatly reduce the amount of HTML that we have to write in a view. It can be say that all the complicated logic to generate a control can be encapsulated into the helper which helps
to keep view simple as much possible.

 

HTML Helpers are categorized into three types:

 

  1. Inline HTML Helpers
  2. Built-in HTML Helpers
  3. Custom HTML Helpers 

 

 

 

Built-in HTML Helpers are further divided into three categories:

 

  1. Standard HTML Helpers
  2. Strongly Typed HTML Helpers
  3. Templated HTML Helpers


 

Standard HTML Helpers 

 

Standard HTML Helpers use to render the most common type of HTML controls like TextBox, DropDown, Radio buttons, Checkbox etc. 

 

 

 

Strongly Typed Helper method

 

Strongly Typed Helper requires lambda expressions. For using Strongly Typed Helper method, Firstly We have to make Strongly Typed View.

 

 

 

Template Helper Method

 

These methods are very flexible and generate the HTML element based on the properties of the model class. Here is the list of all HTML helpers in MVC

Html Control Strogly Typed HtmlHelpers Html helper
Textbox Html.TextBoxFor Html.TextBox
Checkbox Html.CheckBoxFor Html.CheckBox
Dropdown, Combobox Html.DropDownListFor Html.DropDownList
Hidden field Html.HiddenFor Html.Hidden
Html text Html.DisplayFor Html.Display
Generates Html controls based on data type of specified model property Html.EditorFor Html.Editor
Anchor link   Html.ActionLink
TextArea Html.TextAreaFor Html.TextArea
Radio button Html.RadioButtonFor Html.RadioButton
Multi-select list box Html.ListBoxFor Html.ListBox
Password textbox Html.PasswordFor Password
Label Html.LabelFor Html.Label

 

Print
Posted: May 14, 2018,
Categories: .NET Platform,
Comments: 0,
Author: Urish Arora
Rate this article:
5.0

Urish AroraUrish Arora

Other posts by Urish Arora

, Contact author

Please login or register to post comments.

Name:
Email:
Subject:
Message:
x

SEARCH

Categories

«October 2019»
MonTueWedThuFriSatSun
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

  • Featured Posts
  • Recent Posts
  • Recent Comments
Dynamics365Authority is a community platform for Professionals and Students to contribute or share their knowledge and skills on Microsoft Dynamics 365 Technologies. Our primary goal is to invite professionals on Dynamics 365 technology across the world to contribute & share their knowledge and skills through their blogs so that we can help other developers.
Stay updated with Dynamics 365 technology. Improve skills and knowledge from our blogs, articles and code snippets. Learn it. Follow professionals and learn from them.
Unified Service Desk Book(Online Edition) 

FOLLOW US

Stay connected with us on our social media channels for latest articles, blogs posts etc.  We will keep updating regularly on our social media platform and web platform.

FACEBOOK

Follow us on Facebook

 

TWITTER

View all our tweets

 

DYNAMICS365AUTH

Join us now

 

BLOGS

View our blogs

 

 

Latest Blog

Posted: Jun 20, 2019

Overview - Appendix (Unified Service Desk)

This blog is about Appendix

Read more
Posted: Jun 20, 2019

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk

Read more
Posted: Jun 20, 2019

Overview - Performance (Unified Service Desk)

This blog is about the Performance in Unified Service Desk

Read more
RSS

ADDITIONAL RESOURCES

Dynamics 365 Authority.com - Search the library for "Dynamics 365"

  What's New in Dynamics 365

  Dynamics 365 Documentation

  

  Sign-up for 30 days trial

 

 

Recent comments

Ashish:

Nice blog. Very helpful to get all references to white papers at one place.

Previous Next

About Us

Here comes the Dynamics 365 Authority - Great technical blog posts are hidden gems. They are hard to find simply because not enough of us write them in the first place. Yet technical blogging is one of the best things we can do not only for ourselves, but also as members of the wider community of developers.

Dynamics 365 Authority leverages this platform to help developers and users to move from traditional paper-based process to modern digital business process. Dynamics365Authority.com helps your business grow, evolve and transform.

Dynamics365Authority.com is your Digital Transformation Partner

Recent Posts

Overview - Appendix (Unified Service Desk)

This blog is about Appendix
  • 216
  • Article rating: 5.0

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk
  • 303
  • Article rating: 5.0
RSS

Follow Us

 

Tag cloud: Dynamics365Authority.com with Urish Arora; Dynamics365Authority.com; Sales; Leading community site on MS Dynamics 365; Dynamics 365 Authority; Service;Top CRM Blogs; Urish Arora - Australia's leading expert on Digital Transformation;  Digital Transformation; Field Service;Top Articles on MS Dynamics CRM Relationship Insights; Office 365 Security Compliance; Project Service; Microsoft Dynamics 365 for Sales; Relevance Search; Goal Metrics; Activities and Case; Sales Literature;Knowledge Management;

Terms Of UsePrivacy StatementCopyright 2019 by Dynamics365Authority
Back To Top