Friday, October 20, 2006

Fixed "," problem with SmartAutoComplete

Going back to the "," problem the solution seems to be modifing this
in the SmartAutoCompleteExtender.cs  (remember to add a reference to the Microsoft.JScript.dll to use GlobalObject.escape instead of HttpUtility.UrlEncode)

public string GetCallbackResult()
if (_completionItems == null)
return string.Empty;
for (int i = 0; i < _completionItems.Length; i++)
_completionItems[i] = (GlobalObject.escape(_completionItems[i]));

string join = string.Join(",", _completionItems);
return join;

And this in SmartAutoCompleteExtenderBehavior.js

this._onCallbackComplete = function(result, context)
var results = result.split(',');
var decodedResults = new Array();
for (var i=0; i<results.length; i++) {
_cache = { };
_cache[context] = decodedResults;
_autoCompleteBehavior._update(context, decodedResults, false);

The trick is to "escape" things in C#... and "unescape" them in JavaScript (I hope this helps someone else with this issue, it works fine for me)

No comments: