Home > ASP.NET MVC > ASP.NET # MVC # 15 – Html Helper Class , Html Helper Method , Strongly Typed HTML Helpers.

ASP.NET # MVC # 15 – Html Helper Class , Html Helper Method , Strongly Typed HTML Helpers.

Hi Geeks,

Today we will see very important and interesting feature  provided by Microsoft for asp.net MVC called HTML Helper class,HTML Helper methods.

I) HtmlHelper Class  represents support for rendering HTML controls in a view.

    The ViewPage class has an HtmlHelper property named Html like follow



When you look at the methods of HtmlHelper, you’ll notice that it’s pretty sparse. This property is really an anchor point for attaching extension methods. When you import the System.Web.Mvc.Html namespace (imported by default in the default template), the Html property suddenly lights up with a bunch of helper methods.

In following screen shot u can observe it



II) HtmlHelper Methods

ASP.NET MVC 2 includes support for strongly typed HTML helpers, which allow you to specify
Model properties using a Lambda expression rather than as strings.

For example, where you would have previously used <%: Html.TextBox(“PropertyName”) %> in ASP.NET MVC 1, you can now use <%: Html.TextBoxFor(m => m.PropertyName) %>.

Replacing strings with expressions provides a number of benefits, including type checking, IntelliSense, and simpler refactoring.

We have following important strongly typed Html Helper Methods :-

  • Html.Encode
  • Html.TextBox
  • Html.ActionLink and Html.RouteLink
  • Html.BeginForm
  • Html.Hidden
  • Html.DropDownList and Html.ListBox
  • Html.Password
  • Html.RadioButton
  • Html.Partial and Html.RenderPartial
  • Html.Action and Html.RenderAction
  • Html.TextArea
  • Html.ValidationMessage
  • Html.ValidationSummary
    We will go in depth with each HTML HELPER Method in upcoming posts.

Thank You.

Categories: ASP.NET MVC
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: