Open In App

Inline HTML Helper – HTML Helpers in ASP.NET MVC

Last Updated : 23 Jun, 2020
Like Article

HTML Helpers are methods that returns HTML strings. These are used in the view. In simple terms, these are C# methods that are used to return HTML. Using HTML helpers you can render a text box, an area, image tag, etc. In MVC we have many built-in HTML helpers and we can create custom helpers too. Using HTML helpers a view can show model properties and can generate HTML as per the types of properties.

Types of HTML Helpers:

  1. Inline HTML Helper
  2. Built-in HTML Helper
    • Standard HTML helper
    • Strongly Typed HTML helper
    • Templated HTMl Helper
  3. Custom HTML Helper

Inline HTML Helpers
These are the type of helpers that are used on a single view and are used on the same page. inline HTML helpers can be created using @helper tag.

You can create your own HTML Helper with the following syntax.
@helper HelperName(parameters)
    // code
To use the above-created helper we use the following syntax


    Layout = null;
<!--created a inline HTMl Helper 
    with a single string type parameter-->
@helper MyInlineHelper(string[] words)
        <!--Used a foreach loop inside HTML.
 similarly we can use any conditional statement
          or any logic like 
            we use in normal C# code.-->
        @foreach (string word in words)
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
    <title>Inline HTML Helper</title>
        <!--called it inside this 
            div and to get the output-->
        @MyInlineHelper(new string[] {
                  "Delhi", "Punjab", "Assam", "Bihar" })


Drawback of Inline HTML helpers

  • These helpers can only be used with a single view only. You can not use it with multiple views.

Reference: Setup and run code in Visual Studio

Similar Reads

Different Types of HTML Helpers in ASP.NET MVC
ASP.NET provides a wide range of built-in HTML helpers that can be used as per the user's choice as there are multiple overrides available for them. There are three types of built-in HTML helpers offered by ASP.NET. 1. Standard HTML Helper The HTML helpers that are mainly used to render HTML elements like text boxes, checkboxes, Radio Buttons, and
5 min read
ASP.NET MVC Scaffolding
Scaffolding is used to define the code-generation framework used in web applications. It uses T4 templates to generate basic controllers and views for the models. It generates instances for the mapped domain model and code for all CRUD operations. It also reduces the amount of time for developing a standard data operation in the application. Basica
6 min read
ASP.NET MVC Life Cycle
The goal of this article is to provide a good understanding of the MVC pipeline. The life cycle is basically is set of certain stages which occur at a certain time. [caption width="800"]Application Life Cycle[/caption] MVC actually defined in two life cycles, the application life cycle, and the request life cycle. The application life cycle, in whi
8 min read
Caching is the data store just like a database but slightly it is different cache stores, its data in memory so it does not interact with the file system. It also stores data in very simple structures like key-value pairs. So they don't have to execute complex queries to gather data and maintain indexes when they write. Because of this reason cache
7 min read
Difference between ASP and ASP.NET
ASP stands for Active Server Pages. It is a development framework used for building web pages. ASP was introduced in 1998 by Microsoft as its first server-side scripting language. The file extension of ASP pages are .asp and are normally written in VBScript. It is an old but still powerful tool for making dynamic web pages. ASP is a technology (muc
2 min read
ASP Server.GetLastError() Method (ASP 3.0)
The ASP Server.GetLastError() Method is used to return an ASP Error Object which defines the error condition that occurs. Generally, A website uses a Default file \iishelp\common\500-100.asp to encounter an error in the ASP file. Or we can also create our own file. This method is available only before the .asp file has sent any content to the clien
2 min read
What is the difference between display: inline and display: inline-block in CSS?
The display property in CSS is a very useful and commonly used property that contains many values. The display property defines how an HTML element should be displayed on the webpage. The property also specifies the type of box used for an HTML element and how it should be laid out on the page. If we need to display the elements that are laid out a
4 min read
What is the difference between inline-flex and inline-block in CSS?
The display property specifies how an element should be displayed on a webpage. There can be many values, related to this property in CSS. Inline-block and inline-flex are two such properties. Although there are several values that this property can have, to understand the aforementioned, let us first look into three other values: inline, block, an
3 min read
How display: inline is different from display: inline-block in CSS ?
In this article, we will know about the display property in CSS, along with understanding the 2 different property values for display property, i.e., display: inline &amp; display: inline-block properties, &amp; will understand their basic differences &amp; implementation through the examples. The display property facilitates setting the element by
3 min read
Array Helper Methods in ES6
Array Helper Methods in ES6 (JavaScript) are very useful for working with data stored in arrays. Most of the time working as a web developer work with data stored in arrays it may be a simple array of numbers or it may be a complex array of objects where each object is containing a lot of attributes. Array Helper Methods helps lot in working with a
3 min read