AutoComplete中this的问题
最近刚接触AutoComplete,有个问题想请教各位大虾。这是我Server端的代码
string[] strRtn = "this is sample data for the extender to use".Split(' ');
return strRtn;
这是我Client端的代码
<cc1:AutoCompleteExtender
ID="AutoCompleteExtender1"
runat="server"
TargetControlID="TextBox1"
ServicePath="AutoComplete.asmx"
ServiceMethod="HelloWorld"
MinimumPrefixLength="1"
CompletionSetCount="5"
CompletionInterval="1000"
EnableCaching="true"
/>
运行结果本来应该显示“this”的,结果显示成了“function Sys$Serialization$JavaScriptSerializer() { if (arguments.length !== 0) throw Error.parameterCount();}”
请问应该如何解决啊 --------------------编程问答--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AJAX控件之AutoComplete</title>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:TextBox ID="MyAuto" runat="server" Width="191px"></asp:TextBox><br />
<br />
<cc1:AutoCompleteExtender ID="ace" runat="server" CompletionInterval="100" MinimumPrefixLength="1"
ServiceMethod="GetCompletionList" ServicePath="WebService.asmx" TargetControlID="MyAuto">
</cc1:AutoCompleteExtender>
</div>
</form>
</body>
</html>
using System;
using System.Web;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//用以调用Web Service方法签名
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService () {}
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
string[] strRtn = "this is sample data for the extender to use".Split(' ').ToArray();
return strRtn;
}
}
--------------------编程问答--------------------
我这运行出来的结果和我的一样啊
应该显示“this”的
结果显示成了“function Sys$Serialization$JavaScriptSerializer() { if (arguments.length !== 0) throw Error.parameterCount();}”
其他的话,除了“data”显示成了“(data)”外是没有问题的 --------------------编程问答--------------------
还有就是“Split(' ').ToArray();”
我这会报编译错误的
--------------------编程问答--------------------
还有就是“Split(' ').ToArray();”
我这会报编译错误的
--------------------编程问答--------------------
你新建个页面
string[] strRtn = "this is sample data for the extender to use".Split(' ').ToArray();
Response.Write(strRtn[strRtn.Length-1].ToString());看报错不 --------------------编程问答--------------------
会啊,System.Array中没有定义ToArray这个函数 --------------------编程问答--------------------
你什么版本的VS? --------------------编程问答-------------------- 参考:
http://www.cnblogs.com/insus/archive/2011/07/16/2108172.html
补充:.NET技术 , ASP.NET