Show / Hide Table of Contents

    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.:

    • Tag Helpers variant
    • HTML Helpers variant
    <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)
    
    • Improve this Doc
    Back to top © Copyright 2012-2020 MRCollective, Rob Moore, Matt Davies and the contributors to ChameleonForms.