python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
mvc 5 vs mvc 6

MVC 6 tag helpers vNext intelligence

An Introduction to Tag Helpers

Tag Helpers is the biggest feature of MVC 6 that help us to creating and rendering HTML elements in Razor views.

From ASP.NET documentation,

"Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files."

Example for Using Tag Helpers,

Before using Tag Helpers in MVC razor view,

@model MVC6Protal.Models.User

@using (Html.BeginForm())
{
    <div>
        @Html.LabelFor(m => m.Name, "User Name ")
        @Html.TextBoxFor(m => m.Name)
    </div>
    <div>
        @Html.LabelFor(m => m.Email, "User Email ")
        @Html.TextBoxFor(m => m.Email)
    </div>
    <input type="submit" value="Create" />
}

After using Tag Helpers in MVC razor view,

    @model MVC6Protal.Models.User
    @addtaghelper "Microsoft.AspNet.Mvc.TagHelpers"
<form asp-controller="Users" asp-action="Create" method="post">
    <div>
        <label asp-for="Name">User Name </label>
        <input asp-for="Name" />
    </div>
    <div>
        <label asp-for="Email">User Email </label>
        <input asp-for="Email" />
    </div>
    <input type="submit" value="Save" />
</form>


For more detail go to


ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions