Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
foreach (SPListItem news in items)
{


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


    news.update();
}

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

share|improve this question
add comment

2 Answers 2

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
add comment

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 ;)

http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.maxlength.aspx

also

http://stackoverflow.com/questions/9797726/how-to-set-maxlength-for-multiline-textbox

share|improve this answer
add comment

Your Answer

 
discard

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.