Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.08 KB

textarea.md

File metadata and controls

38 lines (25 loc) · 1.08 KB

Textarea Fields

If you need to collect multi-line text data using a textarea then you can use the [DataType] attribute in System.ComponentModel.DataAnnotations to annotate that a string model property is in fact multi-line text, e.g.:

[DataType(DataType.MultilineText)]
public string TextareaField { get; set; }

Default HTML

When using the Default Field Generator then the default HTML of the Field Element will be:

<textarea %validationAttrs% %htmlAttributes% id="%propertyName%" name="%propertyName%">%value%</textarea>

Configurability

Specify rows and columns

You can easily specify the required rows and cols HTML attributes by using the Rows and Cols methods on the Field Configuration, e.g.:

<field for="TextareaField" rows="5" cols="60" />
@* or *@
<field for="TextareaField" fluent-config='c => c.Rows(5).Cols(60)' />
@s.FieldFor(m => m.TextareaField).Rows(5).Cols(60)