SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
foreach (SPListItem news in items)

    TextBoxContents.Text = news["Contents"].ToString();
                            TextBoxContents.MaxLength = 10;


Setting textboxcontents to show max 10 characters is not working why?

share|improve this question

This property is applicable only when the TextMode property is set to TextBoxMode.SingleLine or TextBoxMode.Password.

see full description here.

share|improve this answer

according to msdn:

// Set the maximum characters a user can manually type 
// into the TextBox.
myTextBox.MaxLength = 500;
myTextBox.MinLines = 1;

// Set the maximum number of lines the TextBox will expand to  
// accomidate text. Note: This does not constrain the amount of  
// text that can be typed. To do that, use the MaxLength property.
myTextBox.MaxLines = 5;

I thnk the trick is to make the textbox multiline, but dont take my word on it ;)


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.