HtmlTextArea Server Control Declarative Syntax

Creates a server-side control that maps to the <textarea> HTML element and allows you create a multiline text box.

    OnDataBinding="OnDataBinding event handler"
    OnDisposed="OnDisposed event handler"
    OnInit="OnInit event handler"
    OnLoad="OnLoad event handler"
    OnPreRender="OnPreRender event handler"
    OnServerChange="OnServerChange event handler"
    OnUnload="OnUnload event handler"
        <!-- Control Content -->

Use the HtmlTextArea control to program against the HTML <textarea> element. This control allows you to create a multiline text box. The dimensions of the text box are controlled by the Cols and Rows properties. The Cols property determines the width of the control, while the Rows property determines the height of the control.

The HtmlTextArea control contains a ServerChange event that is raised when the contents of the control change between posts to the server. The event is commonly used to validate the text entered in the control.

The following example demonstrates how to use the OnServerClick event handler of an HtmlInputButton control to display user input from an HtmlTextArea control. The text is displayed by a span control in the Web Forms page. You can use similar techniques to store the text area's values on the server.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >

<title>HtmlTextArea Control</title>

   <script runat="server">
      void SubmitBtn_Click(Object sender, EventArgs e) 
         Span1.InnerHtml = "You wrote: <br />" + TextArea1.Value;

   <h3>HtmlTextArea Example</h3>
   <form id="Form1" runat="server">
      What do you like best about ASP.NET?: <br />
      <textarea id="TextArea1" cols="40" rows="4" runat="server" />
      <input id="Submit1" type="submit" value="Submit" 
             onserverclick="SubmitBtn_Click" runat="server" />
      <br />
      <span id="Span1" runat="server" />

Community Additions