Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi!
Please can you help me to dissociate a text in ASP.NET to let this program to write "Read more..." just like news...??? Thank you.
Posted

The following links help you as starting point.
1.Inserting brakes in a long text[^]
2.Split Long Text into meaningful sentences with certain length using C#[^]

Good luck.
 
Share this answer
 
I wrote the class like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


public string insertBreak(string strMessage, int cdeIndex)
{
String jobname = strMessage;
if (jobname.Length > cdeIndex)
{
int k = cdeIndex;
int j = (jobname.Length / k);


for (int i = 0; i < j; i++)
{
int cdeDifference = 0;
int cdeFindspace = 0;
if ((k + 10) < jobname.Length)
{
cdeFindspace = jobname.IndexOf(" ", k - 2, 10);
}
else { cdeFindspace = -1; }
if (cdeFindspace != -1)
{
cdeDifference = cdeFindspace - k;
k = cdeFindspace;

}
jobname = jobname.Insert(k, "<br />");
if ((k + (k + 6)) < jobname.Length)
{
k = k + (k + 6) + (cdeDifference);
}
else
{
break;

}
}
}
return jobname;
}

But ther is an error in line :

public string insertBreak(string strMessage, int cdeIndex)

The message:
class, delegate, enum, ....

Where is th problem? and how tu use this class for breaking the text? Thank you.
 
Share this answer
 

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