Per visualizzare i primi caratteri di un campo del mi db ho questa funzioncina
Noto però che mi elimina i caratteri html decodificati tipo & % ecc.codice:protected string StrTesto(string testo) { string pippo = ""; string mat = System.Text.RegularExpressions.Regex.Replace(HttpUtility.HtmlDecode(testo), "<[^>]*>", " "); string s = HttpUtility.HtmlDecode(mat.ToString()); Regex re = new Regex("\\w+\\b"); MatchCollection mc = re.Matches(s); short max = 24; if (mc.Count < max) max = (short)mc.Count; for (short i = 0; i < max; i++) pippo += mc[i].Value + " "; return pippo; }

Rispondi quotando