Rank: Newbie Groups: Member
Joined: 2/11/2009 Posts: 1 Points: 3
|
How do I change the highlighting of searched text?
example:
Search: or Return: North Dakota
Right now, it only will highlight the term if it if begins with the search text.
Also, how would I highlight multiple search text?
example:
Search: or ta Return: North Dakota
Edit: I've already got the query changed to return the proper results, so I don't need help with the query, just the modification on the highlighting.
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 80 Points: 152
|
Hi, All you need is to wrap text you want to hilight with <span class="hilighted">text to hilight<span> here is the common code from SuggestionTools.cs class. Code:public static string HighLight(string text, string value) { Regex regex = new Regex("\\s(" + value + ")|^(" + value + ")", RegexOptions.Compiled | RegexOptions.IgnoreCase); return regex.Replace(text, new MatchEvaluator(MatchEval)); }
private static string MatchEval(Match match) { return "<span class=\"hilighted\">" + match + "</span>"; } Hope this helps Thanks.
|