Ajax 控制工具包 AutoCompleteExtender 剥离零并得出幻像值

发布于 2024-07-12 11:59:56 字数 1207 浏览 11 评论 0原文

我正在使用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
...

这显示了两个问题:

  1. 我的零到底发生了什么? 我怎样才能把它们找回来?
  2. 那些“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:

  1. What the hell happened to my zeroes? ANd how can I get them back?
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瀟灑尐姊 2024-07-19 11:59:56

您需要用引号将数组中的每个字符串引起来。 例如, getEJMaps 应该返回一个如下所示的数组:

"00056399"
"00056717"
"00056721"
"00056722"
"00056900"
...

不要忘记您需要用 \ 对引号进行转义

如果这修复了缺失的 0 但不是幻像值,请告诉我,我会尽力提供帮助,如下所示出色地。 我想它会的。

You need to surround each string in the array with quotes. For example, getEJMaps should return an array that looks like:

"00056399"
"00056717"
"00056721"
"00056722"
"00056900"
...

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.

素年丶 2024-07-19 11:59:56
SELECT   
'''' + CustomerShipTo + '''' AS CustomerShipTo   

FROM dbo.CustomerMaster   

这应该有效......
这对我有用

SELECT   
'''' + CustomerShipTo + '''' AS CustomerShipTo   

FROM dbo.CustomerMaster   

This should work.....
It worked for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文