?
Solved

"Multiline Textbox input to database and display in html""wrap problem

Posted on 2009-04-17
3
Medium Priority
?
1,185 Views
Last Modified: 2012-05-06
i have one form in which i m using multiline textbox and entering data in it with line break . this multi line textbox has wrap property true and fixed width so when i m adding data in textbox it automatically wrap but when i m displaying data on aspx form it will not wrap as well as break line it will display as continuos text


<asp:textbox id="txtdetail" runat="server" wrap="true" width="220px"/>
in cs file

database input txtdetail.text

form display
<div style="widht:220px;display:block;overflow:hiddenl">
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</div>

please help me to solve this issue
0
Comment
Question by:jbajaj
  • 2
3 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24165611
Hi,

In textbox the wrap is done by a new line character (\r\n). But html doesn't understand the wrap by a new line char. It is doe by <br />. So you need to wrap by

<div style="widht:220px;display:block;overflow:hiddenl">
<%# DataBinder.Eval(Container.DataItem, "Description").ToString().Replace(Environment.NewLine,"<br/>")%>
</div>

In certain cases the above will not work. The replacement is below

<div style="widht:220px;display:block;overflow:hiddenl">
<%# DataBinder.Eval(Container.DataItem, "Description").ToString().Replace("\n","<br/>").Replace("\r","<br/>")%>
</div>
0
 

Author Comment

by:jbajaj
ID: 24165725
yes GiftsonDJohn:

but when i replace /n by </br> breakline work but wrap will not work  so when i do this my div text will overflow i need this text should display in my fixed width div if text line increase it should come in next line

<div style="widht:220px;display:block;overflow:hiddenl">
<%# DataBinder.Eval(Container.DataItem, "Description").ToString().Replace("\n","<br/>").Replace("\r","<br/>")%>
</div>

0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 2000 total points
ID: 24165869
Try this

<div style="widht:220px;display:block;overflow:hiddenl">
<div style="width: 220px;display:block;">
<%# DataBinder.Eval(Container.DataItem, "Description").ToString().Replace("\n","<br/>").Replace("\r","<br/>")%>
</div>
</div>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question