You are on page 1of 15

Click to edit Master title style

HTML Helper
Instructor: Samra Shahzadi

1
Click to
HTML edit Master title style
HELPER

• The HtmlHelper class renders HTML controls in the razor view. It


binds the model object to HTML controls to display the value of model
properties into those controls and also assigns the value of the
controls to the model properties while submitting a web form. So
always use the HtmlHelper class in razor view instead of writing
HTML tags manually.

2 2
Click to edit Master title style
TextBox

• The HtmlHelper class includes two extension methods TextBox() and


TextBoxFor<TModel, TProperty>() that renders the HTML textbox control <input
type="text"> in the razor view.

3 3
Click to edit Master title style
Textbox

4 4
Click to edit Master title style
CheckBox

• The HtmlHelper class includes two extension methods to


generate a <input type="checkbox"> HTML control in a razor
view: CheckBox() and CheckBoxFor().

5 5
Click to edit Master title style
Cont…

6 6
Click to
Radio edit Master title style
Button

• The HtmlHelper class include two


extension methods to generate a
<input type="radio"> HTML control in a
razor view: RadioButtonFor() and
RadioButton() .

7 7
Click to edit Master title style
Cont…

8 8
Click to edit Master title style
DropDownList

• The HtmlHelper class includes two extension methods to generate the <select> control in
a razor view: DropDownListFor() and DropDownList().

9 9
Click to edit Master title style
Cont…

1010
Click to edit Master title style
Display

• The HtmlHelper class includes two extension methods to


generate html string : Display() and DisplayFor().

1111
Click to edit Master title style
Label

• The HtmlHelper class includes two extension methods to generate


HTML label element: Label() and LabelFor().

1212
Click to edit Master title style
Editor

• ASP.NET MVC includes the method that generates HTML


input elements based on the datatype. The Html.Editor() or
Html.EditorFor() extension methods generate HTML elements
based on the data type of the model object's property.
• The following table list the data types and releted HTML
elements:

1313
Click to edit Master title style
Cont…

1414
Click to edit Master title style

Thank You 

15

You might also like