Hi!
I'm developing a(nother; it's my second!) ASP.NET application that right now is giving me fits.
On one of my screens, the user needs to be able to enter large amounts of text into three database fields. The database fields are all char(350).
I'm having two problems with this. First of all, I found that when editing an existing record, text in the fields would wrap in a manner similar to this:
Wow, what a sorry
performance!The text box is much wider than the text "Wow, what a sorry", so I couldn't figure out why the text was wrapping. I tried setting the Columns property to 90 (which is about how wide the text box actually is), but the text wrapped in the same manner.
This isn't acceptable. How can I fix this?
Second question: While researching potential solutions to the above problem in the documentation in Visual Studio (with no success, which is why I'm here), I also ran across the fact that the MaxLength property doesn't have any effect when the TextBox's Mode is set to MultiLine. That seems fairly stupid in itself, but my question is: Is there any smarter way to prevent the text from being longer than 350 characters than checking it in code?
Thanks,
Tim
![]() |
0 |
![]() |
Are you sure there aren't any type of line breaks or returns within the existing data that may be causing this? If so, you may need to clean your data prior to loading. Secondly, you could always use a CustomValidator with a little JavaScript routine to check the user's input or you could extend the TextBox control itself to work properly. Regardless, there are plenty of articles on how to do either.
Thanks, Ed
Microsoft MVP - ASP/ASP.NET
![]() |
0 |
![]() |
I found that when editing an existing record, text in the fields would wrap in a manner similar to this:
There are probably carriage-returns in the text (<BR> or \n). You may need to filter them out.
The MaxLength property will stop a user from entering too much text. If you jam text in programmatically, like from a database, it will have no effect.
Steve Wellens
My blog
![]() |
0 |
![]() |
Hi Ed,
Thanks for replying.
There are no line breaks in the existing data.
I don't know JavaScript and don't know how to extend the TextBox control, and am not really prepared to learn either under deadline pressure. :) I think it'll be easier to validate the text length in code, but I still need a solution for the wrapping.
Best,
Tim
![]() |
0 |
![]() |
How about setting the TextBox.Width property instead of the Columns property. Does that do anything? It seems awfully odd.
Thanks, Ed
Microsoft MVP - ASP/ASP.NET
![]() |
0 |
![]() |
Hey Steve,
AFAICT there are no line breaks in the existing data.
The documentation (note something I forgot to mention: I'm using Visual Studio 2003) clearly states that the MaxLength property is ignored if the TextMode property is set to MultiLine. Preventing the user from entering too many characters is all I need to do, since the data in these fields will only ever come from users (the data I used in my example in my initial post is just sample data I stuck in the table to make sure I was able to fetch it and display it correctly...which I can, except for the stupid wrapping).
I just tested the TextBox control (with MaxLength set to 350 and TextMode set to MultiLine), and it happily let me gallop right on up to 400 characters without blinking.
![]()
Thanks,
Tim
![]() |
0 |
![]() |
Hey Steve,
AFAICT there are no line breaks in the existing data.
The documentation (note something I forgot to mention: I'm using Visual Studio 2003) clearly states that the MaxLength property is ignored if the TextMode property is set to MultiLine. Preventing the user from entering too many characters is all I need to do, since the data in these fields will only ever come from users (the data I used in my example in my initial post is just sample data I stuck in the table to make sure I was able to fetch it and display it correctly...which I can, except for the stupid wrapping).
I just tested the TextBox control (with MaxLength set to 350 and TextMode set to MultiLine), and it happily let me gallop right on up to 400 characters without blinking.
![]()
Thanks,
Tim
![]() |
0 |
![]() |
Hi again Ed, and thanks for your patience in replying.
The Width property is set to 424px, which presumably corresponds to the width at which I drew the control on my window, and which is the width I want. That looks to correspond roughly to the actual width on my screen, too: my resolution is set at 1280 pixels wide, and the TextBox control looks to be taking up about a third of that width. The text is wrapping long, long before it reaches the right-hand side of the text box; that's the problem. (I guess I really didn't make that clear earlier, apologies for that.)
PS I've just coded my Visual Basic program to truncate the text to 350 characters before it gets included in my SQL INSERT or UPDATE statement, so the user doesn't get the "String or binary data would be truncated" error message on submit. I'm not crazy about that solution, but I can live with it. But I really do need to get the wrapping fixed.
![]() |
0 |
![]() |
I've pretty much ran out of ideas. Strange problem...
Thanks, Ed
Microsoft MVP - ASP/ASP.NET
![]() |
0 |
![]() |