近日研究ajax control toolkit 在使用AutoCompleteExtender自动输入完成控件时发现一个问题,也许这是微软的一个bug吧。如果返回的数组是纯数字,那么将变成undefined(非0情况)或null(0为null)。

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetCompletionList(string prefixText, int count, string contextKey)
    {       
         string[] s = new string[3];

        for (int i = 0; i < 3; i++)
        {
            s[i] = i.ToString();
        }

         return s;   
    }
在上面情况下,将返回:null,undefined,undefined,如果我们改成

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetCompletionList(string prefixText, int count, string contextKey)
    {       
         string[] s = new string[3];        
        s[0] = "中文";
        s[1] = "abc";
        s[2] = "123abc";        
         return s;   
    }
那么将返回真确的值。
我还不清楚为什么数字字符串会变成undefined和null,也许是和javascript定义有关系吧!

posted on 2007-09-24 14:48 阿米 阅读(485) 评论(3)  编辑 收藏 网摘 所属分类: .NETWebDevelop

  回复  引用  查看    
2007-09-29 17:17 | namhyuk      
WebService时的情况也是这样,感觉有点郁闷。中文开头的没问题。
  回复  引用  查看    
2007-12-05 11:13 | 李峰艳      
这是一个小BUG而已
  回复  引用  查看    
2007-12-05 11:17 | 李峰艳      
最近发觉这个控件有时候会不能激活GetCompletionList方法,不知道是什么情况下出现,朋友遇到过如果有心得请回下

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索
[推荐职位]上海盛大网络招聘架构师



China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
近千种 9-95 新二手计算图书火热销售中!
开发者征途系统新作:《设计模式——基于C#的工程化实现及扩展》

相关文章:

相关链接: