This project is read-only.

Google Marker JavaScript Error Fix

Feb 14, 2008 at 10:08 PM
When populating the GoogleMarkers, there is a possibility of creating JavaScript errors if the text property contains any single quotes. I changed the ToString method in the GoogleMarker class to do the following... Lines 251-253 became this:

StringBuilder config = new StringBuilder("{");
config.AppendFormat("draggable:{0},", this.Draggable.ToString().ToLower());
if (System.Text.RegularExpressions.Regex.IsMatch(this.Text, "'"))
{
config.AppendFormat("text:'{0}',", System.Text.RegularExpressions.Regex.Replace(this.Text, "'", "'"));
}
else
{
config.AppendFormat("text:'{0}',", this.Text);
}

I could have opted for not doing a prior check for the single quote, but performing a replace over every string could create too much overhead for large applications.
Feb 15, 2008 at 7:00 AM
Hi,
I see. Thanks.
But you are using older release.
Please, get latest release 2.8 and there you'll find all strings are passed through Util.Encode.
That method do the proper C# to JS string encoding.
Regards
Feb 15, 2008 at 1:03 PM
Wow! Indeed. Thanks for the quick release schedule. We were just talking about adding some of those client-side features yesterday.