MVC HTML Helpers Methods

In this article we will learn what are HTML helper Methods that comes within MVC framework!!!!…

So What are HTML Helper Methods ???

Html Helpers methods are equivalent to ASP.Net web form controls, enables you to render HTML content, modify the HTML output .

  • HTML Helpers are more light  weight.
  • It does not have event model and viewstate.

HTML Links

The easiest way to render HTML link is to use HTML.ActionLink() helper . With MVC , the HTML.ActionLink() does not link to view rather it creates a link to controller.



HTML Helpers


HTML.ActionLink() has several properties:-

  • .linkText  – The link text (label).
  • .actionName – Te target action .
  • .routevalues  – The value passed to the Action .
  • .controllerName – The target Controller
  • .htmlAttributes—The set of attributes to the link
  • .protocol– The link protocol
  • .hostname—The hostname for the link
  • .fragment—The anchor target for the link.
  • You can pass values to a controller action.
  • For example, you can pass the id of a database record to a database edit action

Razor Syntax:

HTML Helpers

The HTML.ActionLink() helper above,outputs the following HTML

<a href=”/Home/Edit/3″>Edit Record</a>

  • Html helpers can be used to render (modify and output) HTML form elements.
  • BeginForm() – method renders a form that will be handled by a controller action method.
  • EndForm() -This method provides an alternative way to end the form instead of using a block when you call the  Begin Form methods.
  • TextArea() – The HtmlTextArea control corresponds to the <textarea> HTML element that allows you to create a multiline text box on a Web page.
  • CheckBox() – HtmlHelper. CheckBox Method . Returns an HTML check box control for use in a web page
  • RadioButton() -HtmlHelper. RadioButton Method . Returns an HTML RadioButton control for use in a web page.
  • ListBox()-HtmlHelper. ListBox Method . Returns an HTML ListBox control for use in a web page.
  • DropDownList()-HtmlHelper. DropDownList Method . Returns an HTML DropDownList control for use in a web page.
  • Hidden() –  Hidden Method (HtmlHelper, String, Object) Returns a hidden input element by using the specified HTML helper, the name of the form field, and the value
  • Password() – Password Method (HtmlHelper, String) Returns a password input element by using the specified HTML helper and the name of the form field.

Related Article: Data Entry Form using Simple HTML Helper In MVC

I hope you will refer this article for your need. Happy Coding!!!.

Leave a Comment

Your email address will not be published.