Home > Getting Started > ASP.NET Syntax > ASP.NET Syntax for HTML Controls > HtmlTextArea
ASP.NET Syntax ASP.NET Syntax for HTML Controls
Creates a scrollable text box control.
Declarative Syntax
<textarea id="accessID" runat="server"
cols = "numberofcolsintextarea"
name = "namepassedtobrowser"
rows = "numberofrowsintextarea"
onserverchange = "onserverchangehandler">
textareacontent
</textarea>
For information on the individual members of this class, see HtmlTextArea in the class library.
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.
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.
- 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>
- 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>
Web Forms Events and Handlers HtmlTextArea Class