Export (0) Print
Expand All

TextAreaExtensions Class

Represents support for HTML textarea controls.

System.Object
  System.Web.Mvc.Html.TextAreaExtensions

Namespace:  System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

public static class TextAreaExtensions

  NameDescription
Public methodStatic memberTextArea(HtmlHelper, String)Returns the specified textarea element by using the specified HTML helper and the name of the form field.
Public methodStatic memberTextArea(HtmlHelper, String, IDictionary<String, Object>)Returns the specified textarea element by using the specified HTML helper, the name of the form field, and the specified HTML attributes.
Public methodStatic memberTextArea(HtmlHelper, String, Object)Returns the specified textarea element by using the specified HTML helper and HTML attributes.
Public methodStatic memberTextArea(HtmlHelper, String, String)Returns the specified textarea element by using the specified HTML helper, the name of the form field, and the text content.
Public methodStatic memberTextArea(HtmlHelper, String, String, IDictionary<String, Object>)Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, and the specified HTML attributes.
Public methodStatic memberTextArea(HtmlHelper, String, String, Object)Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, and the specified HTML attributes.
Public methodStatic memberTextArea(HtmlHelper, String, String, Int32, Int32, IDictionary<String, Object>)Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, the number of rows and columns, and the specified HTML attributes.
Public methodStatic memberTextArea(HtmlHelper, String, String, Int32, Int32, Object)Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, the number of rows and columns, and the specified HTML attributes.
Public methodStatic memberTextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>)Returns an HTML textarea element for each property in the object that is represented by the specified expression.
Public methodStatic memberTextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IDictionary<String, Object>)Returns an HTML textarea element for each property in the object that is represented by the specified expression using the specified HTML attributes.
Public methodStatic memberTextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, Object)Returns an HTML textarea element for each property in the object that is represented by the specified expression using the specified HTML attributes.
Public methodStatic memberTextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, Int32, Int32, IDictionary<String, Object>)Returns an HTML textarea element for each property in the object that is represented by the specified expression using the specified HTML attributes and the number of rows and columns.
Public methodStatic memberTextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, Int32, Int32, Object)Returns an HTML textarea element for each property in the object that is represented by the specified expression using the specified HTML attributes and the number of rows and columns.
Top

The TextAreaExtensions class contains methods that extend the HtmlHelper class. Each extension method renders an HTML textarea element. The TextArea method renders an element that enables the user to enter multiple lines of text that is then submitted to the Web server.

The following example shows how to create a form that enables the user to enter text for an article and to enter the article title. The form provides a TextArea helper method that is used to enter the article text. The method also passes an anonymous object that contains the HTML attributes that are used to render the textarea element.

When the user submits the form, the TextArea action method handles the request. This method uses a regular expression to replace newline (\n) characters with HTML br elements in order to retain paragraph formatting.

The following example shows the view that is rendered in order to display the text that was submitted.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft