ASP.NET TextBox MultiLine Incorrect Documentation

[Update: The link to the TextBox class from the ASP.NET TextBox Web Server Control points to the Windows Forms TextBox, not the Web Controls TextBox. Balls!]

If you’re running into trouble when using the TextBox class in ASP.NET, the MultiLine property and the Microsoft .NET Framework SDK Documentation, it’s probably because the documentation is wrong. The documentation that ships with v1.1 says that you can use the ‘Multiline’ property of the TextBox class (which is actually a property of the TextBoxBase class) to toggle the TextMode property like this:

private void CreateMyMultilineTextBox() {
  // Create an instance of a TextBox control.
  TextBox textBox1 = new TextBox();

  // Set the Multiline property to true.
  textBox1.Multiline = true;
  ....
}

If you do what the documentation says, you’ll get a compiler error that says this:

error CS0117: 'System.Web.UI.WebControls.TextBox' does not contain a definition for 'Multiline'

So instead, use the the TextBoxMode enumeration and the TextMode property:

private void CreateMyMultilineTextBox() {
  // Create an instance of a TextBox control
  TextBox textBox1 = new TextBox();

  // use the TextMode property and the TextBoxMode enumeration
  textBox1.TextMode = TextBoxMode.MultiLine;
  ....
}

All of this is documented correctly online.

One thought on “ASP.NET TextBox MultiLine Incorrect Documentation”

Leave a Reply to Molly Bostic Cancel reply

Your email address will not be published. Required fields are marked *