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.

This entry was posted in .NET. Bookmark the permalink.

One Response to ASP.NET TextBox MultiLine Incorrect Documentation

  1. Molly Bostic says:

    Hi Aaron,
    I’m sorry this documentation bug caused problems for you. Is the page from which you accessed the bad link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcontextboxwebcontrol.asp (or the equivalent in the off-line documentation)? I’ll file a doc bug so we fix the link in our next release.
    – Molly (.NET Framework User Education Team)

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>