Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

HtmlTextArea.Cols Property

Gets or sets the width (in characters) of the HtmlTextArea control.

[Visual Basic]
Public Property Cols As Integer
[C#]
public int Cols {get; set;}
[C++]
public: __property int get_Cols();
public: __property void set_Cols(int);
[JScript]
public function get Cols() : int;
public function set Cols(int);

Property Value

The width (in characters) of the HtmlTextArea control. The default value is -1, which indicates that this property is not set.

Remarks

Use the Cols property to specify or determine the width (in characters) of the HtmlTextArea control. If you enter text that is longer than the width of the text box, the text automatically continues on the next line of the control.

To control the height of the control, set the Rows property.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the Cols property to control the width of the HtmlTextArea control.

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

<html>
<head>

   <script runat="server">

      Sub SubmitBtn_Click(sender As Object, e As EventArgs) 
      
         TextArea1.Cols = CInt(Select1.Value)
         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>

      Select column width: <br>

      <select id="Select1" 
              Multiple="False"
              runat="server">

         <option value="10" Selected="True"> 10 </option>
         <option value="20"> 20 </option>
         <option value="30"> 30 </option>
         <option value="40"> 40 </option>
         <option value="50"> 50 </option>
         <option value="60"> 60 </option>

      </select>

      <br><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) 
      {
         TextArea1.Cols = Convert.ToInt32(Select1.Value);
         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>

      Select column width: <br>

      <select id="Select1" 
              Multiple="False"
              runat="server">

         <option value="10" Selected="True"> 10 </option>
         <option value="20"> 20 </option>
         <option value="30"> 30 </option>
         <option value="40"> 40 </option>
         <option value="50"> 50 </option>
         <option value="60"> 60 </option>

      </select>

      <br><br>

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

      <p>

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

   </form>

</body>
</html>

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

<html>
<head>

   <script runat="server">

      function SubmitBtn_Click(sender, e : EventArgs) 
      {
         TextArea1.Cols = Convert.ToInt32(Select1.Value);
         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>

      Select column width: <br>

      <select id="Select1" 
              Multiple="False"
              runat="server">

         <option value="10" Selected="True"> 10 </option>
         <option value="20"> 20 </option>
         <option value="30"> 30 </option>
         <option value="40"> 40 </option>
         <option value="50"> 50 </option>
         <option value="60"> 60 </option>

      </select>

      <br><br>

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

      <p>

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

   </form>

</body>
</html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript 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 | Rows

Show:
© 2014 Microsoft. All rights reserved.