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

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.