Click here to Skip to main content
16,012,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a asp.net Multiline textbox. When I populate a continuous text in that then the control is getting expanded. I could not give a fixed width because in design width is specified as %

Now i should stop the control geting expanded.
ASP.NET
<asp:TextBox ID="txtProperShippingName" TabIndex="35"
      runat="server" MaxLength="120" Width="96%" TextMode="MultiLine" Rows="3">
 </asp:TextBox>


I will give u an ex say i have text "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" now this is continuous text because of this continuous text the control is getting expanded more over width is specified in % this is my exact problem
Posted
Updated 12-Jul-12 20:42pm
v3

Hi M.Ravibalaji,

You can apply "text-wrap" or "word-wrap" styles to your textbox or put a div tag with "text-wrap" or "word-wrap" styles and put your textbox in that div tag.

e.g. style="word-wrap: break-word;"

Hope this will help you.

Regards,
Ambicaprasad Maurya
 
Share this answer
 
We had resolved this issue using a method, which would display certain charaters or words and on hover, display whole text as a tooltip or some modal popup.
Display cropped text like "AAAAAAAAAAAAAAAAAAAAAA...." and on hover of it display the whole text.
Not sure if your customer would agree to this design change, you can however try.
 
Share this answer
 
Hi M.Ravibalaji,


I've given your above mentioned code a real try & I found this working as it should. It's not getting expanded. I advise you to check your code if any style information you've attached to this text box. You can also try putting this inside a DIV.

Hope this helps !!

Happy Coding :)
 
Share this answer
 
Comments
M.Ravibalaji 13-Jul-12 5:11am    
try it in ie. then u can find this control compressing the other fields
Sunny_Kumar_ 13-Jul-12 5:52am    
I did try in IE. I'm using IE9 and it worked fine. Did you try putting a DIV around the text box ?
Hi Ravi..

No issue in it.. It is very Simple..
Just give this code in your text box control..

style="resize:none"

as shown below...

XML
<asp:TextBox ID="txtProperShippingName" TabIndex="35"
      runat="server" MaxLength="120" Width="96%" TextMode="MultiLine" style="resize:none" Rows="3">
 </asp:TextBox>
 
Share this answer
 
http://geekswithblogs.net/mahesh/archive/2007/12/27/asp.net-textbox.multiline-maxlength.aspx[^] describes a couple of workarounds that could help you out. MaxLength is not supported by the multiline control as per this article.
 
Share this answer
 
Comments
M.Ravibalaji 13-Jul-12 2:37am    
just leave about the max length. I will give u an ex say i have text "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" now this is continuous text because of this continuous text the control is getting expanded more over width is specified in % this is my exact problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900