Ajax 控制工具包 AutoCompleteExtender 剥离零并得出幻像值
我正在使用Ajax Control Toolkit中的AutoCompleteExtender,它的行为很奇怪。
我的服务方法如下所示:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getEJMaps(string prefixText, int count)
{ // method that returns the auto-suggest for the EJMaps positions
string file_location = HttpContext.Current.Server.MapPath("~") + Utils.Settings.Get("attachments") + "ejmaps\\ejmaps.xml";
XElement x = XElement.Load(file_location);
string[] positions = (from p in x.Descendants("position") where p.Value.StartsWith(prefixText) orderby p.Value select p.Value).ToArray();
if (positions.Count() == 0)
return new string[] { "No Matching Results" };
else return positions;
}
如果我在测试页面中使用值 getEJMaps("00056", 4) 调用它,它工作正常,我会得到以下结果:
00056399
00056717
00056721
00056722
00056900
...
这正是我想要的,但是当我将它绑定到 TextBox 并输入 00056 时,我得到结果:
56399
24015
24017
56717
56721
...
这显示了两个问题:
- 我的零到底发生了什么? 我怎样才能把它们找回来?
- 那些“240xx”数字是从哪里来的? xml 文档中甚至没有任何包含这些值的内容!
我对此完全困惑,请帮助我:)
I am using the AutoCompleteExtender from the Ajax Control Toolkit and it is behaving stragely.
My service method is shown here:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getEJMaps(string prefixText, int count)
{ // method that returns the auto-suggest for the EJMaps positions
string file_location = HttpContext.Current.Server.MapPath("~") + Utils.Settings.Get("attachments") + "ejmaps\\ejmaps.xml";
XElement x = XElement.Load(file_location);
string[] positions = (from p in x.Descendants("position") where p.Value.StartsWith(prefixText) orderby p.Value select p.Value).ToArray();
if (positions.Count() == 0)
return new string[] { "No Matching Results" };
else return positions;
}
And it works fine, if I call it in a test page with the values getEJMaps("00056", 4) I get these results:
00056399
00056717
00056721
00056722
00056900
...
Which is exactly what I want, but when I tie it to a TextBox and type in 00056, I get the results:
56399
24015
24017
56717
56721
...
Which shows two problems:
- What the hell happened to my zeroes? ANd how can I get them back?
- Where did those "240xx" numbers come from? There aren't even any in the xml document with those values whatsoever!
I am totally baffled by this, please help me out :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要用引号将数组中的每个字符串引起来。 例如, getEJMaps 应该返回一个如下所示的数组:
不要忘记您需要用 \ 对引号进行转义
如果这修复了缺失的 0 但不是幻像值,请告诉我,我会尽力提供帮助,如下所示出色地。 我想它会的。
You need to surround each string in the array with quotes. For example, getEJMaps should return an array that looks like:
Don't forget you need to escape the quotes with a \
If this fixes the missing 0's but not the phantom values, let me know and I'll try to assist with that as well. I'm thinking it will though.
这应该有效......
这对我有用
This should work.....
It worked for me