Wednesday 7 October 2015

HTML Helpers


HTML helpers help to render HTML controls in the view.

eg:
<%= Html.TextBox("Name") %>

Or

<%= Html.CheckBox("Married") %>

What is the difference between “HTML.TextBox” vs “HTML.TextBoxFor”?

Both of them provide the same HTML output, “HTML.TextBoxFor” is strongly typed while
“HTML.TextBox” isn’t.

Below is a simple HTML code which just creates a simple textbox with “CustomerName” as name.

Html.TextBox("CustomerName")

Below is “Html.TextBoxFor” code which creates HTML textbox using the property name
‘CustomerName” from object “m”.

Html.TextBoxFor(m => m.CustomerName)

No comments:

Post a Comment