Describe HTML helper in ASP.Net MVC.

Solution

HTML helpers are static extension methods defined in InputExtensions class. These helper methods render HTML markup 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

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media