0

I'm working a comment section page where it allows the user to leave a comment. I need assistance in my layout for displaying the comments into the repeater control. I used to put the comments inside the div element of the item and alternatingitem template of the repeater. And as a result, the comment would go straight along the line in the div element if the user is typing too many words or paragraph. What I want is to put a limit where the text will stop and proceed to the next line of the div element. How would I do that?What is the best way?Any suggestion? Here's my layout for the repeater control where I used to insert the comments.

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">

<HeaderTemplate>
</HeaderTemplate>  
<ItemTemplate>  
<tr>
<td >
<div style="background-color:#FFFF66" >
<%# Eval("Name") %> Says...
<%# Eval("Comments") %>
</div>
</td>
</tr> 
</ItemTemplate> 
<AlternatingItemTemplate>  
<tr>
<td >
<div style="background-color:#CCFF33" >
<%# Eval("Name")%> Says...
<%# Eval("Comments")%>
</div>
</td>
</tr> 
</AlternatingItemTemplate>  
<SeparatorTemplate >
<br />   
</SeparatorTemplate>  
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
timmack
  • 590
  • 2
  • 12
  • 43
  • You could simply set a fixed width to the Div, or use word-wrap (CSS) OR optionaly you could go use a C# method to count the spaces, and add a
    tag after X-amount of words. If you would like an example, just ask here
    – Riaan Walters Mar 24 '13 at 19:09
  • So how do i simply set its fixed width in the Div. I tried to set its width but the words being enter will still continue go straight instead of jumping to its next line. – timmack Mar 24 '13 at 19:20
  • 1
    how do I use word-wrap in css as well?Can you give some example of this?Thanks – timmack Mar 24 '13 at 19:21
  • 1
    http://stackoverflow.com/questions/1638223/is-there-a-way-to-word-wrap-text-in-a-div – Rohit Kumar Mar 24 '13 at 19:59

2 Answers2

1

you could do like this to set div border

    <div style="border:black 2px">

        <!-- content goes here -->
     </div>
Rohit Kumar
  • 1,018
  • 3
  • 12
  • 23
  • the words still doesn't break to its new line.It still continue going straight until the last word. I just want to wrap it inside my div element. – timmack Mar 24 '13 at 19:53
  • because I'm working with comment section page so I need to wrap the words being entered by the users just like any other comment page like this forum. – timmack Mar 24 '13 at 19:57
1

Refer to Is there a way to word-wrap long words in a div?

I had the same problem with a repeater inside a div and I found the answer there.

/* Source: http://snipplr.com/view/10979/css-cross-browser-word-wrap */

.wordwrap { 
   white-space: pre-wrap;      /* CSS3 */   
   white-space: -moz-pre-wrap; /* Firefox */    
   white-space: -pre-wrap;     /* Opera <7 */   
   white-space: -o-pre-wrap;   /* Opera 7 */    
   word-wrap: break-word;      /* IE */
}
Ghaamae
  • 71
  • 1
  • 10