User-1569779262 posted
Hi anders,
Thanks for Replying. The way you purposed is really good. But still it leaves some tags like /n,etc. So, to overcome that I had created one procedure & then called it like :
public static String GetStrippedString(String data, Int32 MaxLength)
{
data = Regex.Replace(data, @"<(.|\n)*?>", string.Empty);
MatchCollection DataWords = Regex.Matches(data, @"\w*");
Int32 TotalWords = DataWords.Count;
String NewString = "";
foreach (Match m in DataWords)
{
if (m.Index >= MaxLength)
{
NewString += "...";
break;
}
if (m.Value == "")
{
if (m.Index < data.Length)
NewString += data.Substring(m.Index, 1);
}
else
NewString += m.Value;
}
return NewString;
}
And called it like:
<div><%# UtilityFunctions.GetStrippedString(Convert.ToString(Eval("Product_SDesc")), 50)%></div>