Tuesday 9 August 2016

HTML Helper In ASP.NET MVC

Posted by : Manav Pandya

What is "HTML" in ASP.NET MVC ?

HTML helpers are static extension methods defined in InputExtensions class

These helper methods render HTML maup in view. ASP.Net MVC framework provides different inbuilt helper methods to render different HTML controls.

Below table describes the commonly used HTML helper methods .


Name
Description
@Html.Label("Name")
Display Label
@Html.LabelFor(model=>model.Name)
Display model binded label control
@Html.TextBox("textboxName")
Display textbox control
@Html.TextBoxFor(model=>model.PropertyName)
Display model binded textbox
@Html.TextArea("name")
Display Text area
@Html.CheckBox("name")
Display checkbox
@Html.CheckBoxFor(model=>model.PropertyName)
Display model binded checkbox
@Html.RadioButton("name")
Display radio button
@Html.RadioButtonFor(model=>model.PropertyName)
Display model binded radio button
@Html.Password("name")
Display password field
@Html.PasswordFor(model=>model.PropertyName)
Display model binded password field
@Html.Hidden("name")
Display hidden field
@Html.HiddenFor(model=>model.PropertyName)
Display Model binded hidden field