Tuesday, May 28, 2019

Helper Tag in MVC | How to Reuse html code in View

Inline Html Helpers - These are create in the same view by using the Razor @helper tag. 
These helpers can be reused only on the same view.
    @helper ListingItems(string[] items)
    {
    <ol> @foreach (string item in items)
        {
        <li>@item</li> 
        } 
    </ol> 
    }

 <h3>Header</h3>
<br />
@ListingItems(new string[] { "C", "C++", "C#" })
<br />

<h3>Footer</h3>
<br />
@ListingItems(new string[] { "Naveen", "Kumar", "Sharma" })
<br />

No comments:

Post a Comment

javascript Filter/index off

 var family = [{"name":"Jack",  "age": 26},               {"name":"Jill",  "age"...