This documentation is archived and is not being maintained.

HtmlTextArea.Value Property

Gets or sets the text entered in the HtmlTextArea control.

[Visual Basic]
Public Property Value As String
[C#]
public string Value {get; set;}
[C++]
public: __property String* get_Value();
public: __property void set_Value(String*);
[JScript]
public function get Value() : String;
public function set Value(String);

Property Value

The text entered in the HtmlTextArea control. The default value is String.Empty.

Remarks

Use the Value property to programmatically control the text entered in the HtmlTextArea control. This property is commonly used to retrieve the text entered in the text box, but you can also use it to specify the text to display in the control. This is useful if you want to provide a default value or display a message in the HtmlTextArea control.

CAUTION   This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.

Example

[Visual Basic, C#] The following example demonstrates how to use the Value property to determine the contents of the HtmlTextArea control. The contents are then displayed in the Web page.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      Sub SubmitBtn_Click(sender As Object, e As EventArgs) 
      
         Span1.InnerHtml = "You wrote: <br>" + TextArea1.Value
      
      End Sub

   </script>

</head>
<body>

   <form runat=server>

      <h3>HtmlTextArea Example</h3>

      Enter your comments: <br>

      <textarea id="TextArea1" 
                runat="server"/>

      <br>

      <input type="submit"  
             value="Submit" 
             OnServerClick="SubmitBtn_Click" 
             runat="server"/>

      <p>

      <span id="Span1" 
            runat="server" />

   </form>

</body>
</html>

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

<html>
<head>

   <script runat="server">

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

   </script>

</head>
<body>

   <form runat=server>

      <h3>HtmlTextArea Example</h3>

      Enter your comments: <br>

      <textarea id="TextArea1" 
                runat="server"/>

      <br>

      <input type="submit"  
             value="Submit" 
             OnServerClick="SubmitBtn_Click" 
             runat="server"/>

      <p>

      <span id="Span1" 
            runat="server" />

   </form>

</body>
</html>

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

HtmlTextArea Class | HtmlTextArea Members | System.Web.UI.HtmlControls Namespace | String.Empty

Show: