Wrap the text in div tag! - DOTNET

This is a discussion on Wrap the text in div tag! - DOTNET ; Hi, I would like to wrap the text in div tag according to its width. The text don't have any space. Anyone please suggest me how to do this....

+ Reply to Thread
Results 1 to 2 of 2

Wrap the text in div tag!

  1. Default Wrap the text in div tag!

    Hi, I would like to wrap the text in div tag according to its width.
    The text don't have any space. Anyone please suggest me how to do this.


  2. Default RE: Wrap the text in div tag!

    Hi there,

    Unfortunatelly, HTML related solutions like <wbr/> (not in HTML spec) tag or
    word-break css attribute (IE only) are partially working for some browsers
    only. But don't worry, there's a generic resolution by inserting an invisible
    span inside long words (my example works for plain text with encoded
    characters, if you want to break long words in HTML formatted text it's gonna
    be harder):

    using System.Text.RegularExpressions;
    using System;

    public static class HtmlUtils
    {
    public static string BreakLongWords(string input, int maxWordLength)
    {
    // anonymous method can be used in this case
    MatchEvaluator evaluator = delegate(Match match)
    {
    string text = match.Value;
    int length = text.Length;

    // this is for html encoded characters that
    // are present in the plain text
    int startIndex = text.LastIndexOf('&',
    length - 1, Math.Min(7, length));

    return startIndex != -1 ?
    text.Insert(startIndex, WordBreak) :
    text + WordBreak;
    };

    string pattern = string.Format(@"[^\s-]{{{0}}}", maxWordLength);

    return Regex.Replace(input, pattern, evaluator);
    }

    private const string WordBreak =
    "<span style=\"font-size:0px;color:transparent;\"> </span>";

    }

    usage:

    <div runat="server" style="width: 200px; border: solid 1px black" id="myDiv">
    </div>

    and the code behind/beside:
    myDiv.InnerHtml = HtmlUtils.BreakLongWords(
    "thisIsVeryLongTextWhichWillBeBrokenIntoSmallerPieces", 30);

    You should be fine from this point on.

    HTH
    --
    Milosz


    "Santel" wrote:

    > Hi, I would like to wrap the text in div tag according to its width.
    > The text don't have any space. Anyone please suggest me how to do this.
    >
    >


+ Reply to Thread

Similar Threads

  1. Text Varaible does not word wrap in text frame CS3
    By Application Development in forum Adobe Indesign
    Replies: 18
    Last Post: 06-26-2007, 12:34 PM
  2. Re: Text Wrap
    By Application Development in forum Adobe illustrator
    Replies: 0
    Last Post: 05-24-2007, 01:21 PM
  3. JLabel Text Wrap
    By Application Development in forum Java
    Replies: 4
    Last Post: 03-14-2007, 07:08 PM
  4. help.....text wrap
    By Application Development in forum Adobe illustrator
    Replies: 1
    Last Post: 10-05-2006, 11:21 PM
  5. text wrap for replies
    By Application Development in forum Pine
    Replies: 2
    Last Post: 07-17-2006, 03:28 PM