ConvincingMail - Email Marketing SoftwareConvincingMail
 
Email Marketing Software

Welcome Guest Search | Active Topics | Members | Log In | Register

Advanced Auto Suggest - Highlight in Description? Options · View
Darren
Posted: Monday, April 21, 2008 2:35:19 PM
Rank: Guest
Groups: Guest

Joined: 11/18/2007
Posts: 15
Is there a way to enable highlighting in the Description text of a SuggestionItem? I tried making the following change:

(Converted to VB.NET)

Old:
SuggestionTools.SerializeValueToJson(sb, "Description", Description).Append(",")

New:
SuggestionTools.SerializeValueToJson(sb, "Description", SuggestionTools.HighLight(Description, tryValue)).Append(",")

... but it didn't highlight the tryValue in the Description when rendered on the page. I'm assuming there's something I probably need to do in the JavaScript file?

Any suggestions?
trooper
Posted: Tuesday, April 22, 2008 3:13:47 AM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 23
Hi
you r right in this:
SuggestionTools.SerializeValueToJson(sb, "Description", SuggestionTools.HighLight(Description, tryValue)).Append(",")

it uses
this code to highlight:
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.ToString() + "</span>";
       }

the regexp pattern matches all words starting with a white space or begining of the line.
umm actually I just realized that the passed value could contain special pattern chars and the method will not work as it should.
so check if your tryValue is alfa-numeric


You can create your own method to highlight just wrap the text you want to highlight with <span class=\"hilighted\">highlighted text here</span>
Thanks
Users browsing this topic
Guest


Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.