asp.net.ph

Skip Navigation LinksHome > Getting Started > ASP.NET Syntax > ASP.NET Syntax for HTML Controls > HtmlTextArea

HtmlTextArea Control Syntax

ASP.NET Syntax   ASP.NET Syntax for HTML Controls


Creates a scrollable text box control.

Declarative Syntax

For information on the individual members of this class, see HtmlTextArea in the class library.

Working with HtmlTextArea

The HtmlTextArea control is a multiline input control that lets the user enter text. The display width of HtmlTextArea is determined by its Cols property, and the display height is determined by the Rows property.

The HtmlTextArea control enables programming of the HTML <textarea> element. The control is typically used when you want to gather feedback from your users.

This sample illustrates use of the HtmlTextArea control.

Retrieving Values from an HtmlTextArea Control

The following example shows use of a simple form submit handler 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.

Retrieving the Value of an HtmlTextArea Control
Run Sample | View Source
  1. In the <body> of the Web Forms page, define the HtmlForm to contain the HtmlTextArea control, an HtmlInputButton control to trigger the event handler, and the span control to render the textarea’s value.
    <body>
    <div class = "header"><h3>HtmlTextArea Example</h3></div>
    
    <form runat="server">
    
       <p>What do you like best about ASP.NET?</p>
    
       <textarea id="myTextArea" runat="server" cols=40 rows=4 />
    
       <p><input type=submit value="Submit" runat="server"
          onServerClick = "submitHandler">
    
       <p><span id="Message" runat="server" />
    
    </form>
    
    </body>
  2. In the <head> of the page, define the handler for the HtmlInputButton click event.
    <head>
    <script language="C#" runat="server">
       void submitHandler ( Object sender, EventArgs e ) {
          Message.InnerHtml = "You wrote: <p>" + myTextArea.Value;
       }
    </script>
    </head>
See Also

Web Forms Events and Handlers   HtmlTextArea Class



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note