AutoCompleteExtender在VS2010中调试时能够从数据库中查询相关的结果,实现自动提示功能,但是当我把这个网站发布后,在iis中配置这个生成的网站,然后在IE地址栏中输入刚才配置好的地址,就不能实现这个功能,没有显示任何数据
弄了挺久的 还是不知道怎么回事
弄了挺久的 还是不知道怎么回事
解决方案 »
- aspose.cells导出excel怎么显示为数字格式?
- 创建模态窗体,单击按钮弹出窗体后,就不能弹出其他的窗体了
- 如何将动态创建的textbox里面的内容回写到文本文件?
- 多线程 求教
- 求“用水晶报表打印datagridview里面的数据”的代码
- 现在比较好的VS.net版本是哪个??
- 未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中
- 关于程序集的强名称
- 用windows nt 能装.net 吗?
- 有必要学习GDI+吗
- 关于DateTime.Now
- 验证接收cookie的页面的时候,是判断cookie不为空,还是cookie.value不为空哈
在设计页面AutoCompleteExtender这个控件不显示
在HTML中式这样写的:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtKeyword" Enabled="True" ServicePath="~/Landing/GetKeywords.asmx"
ServiceMethod="GetKeyword" CompletionSetCount="7" MinimumPrefixLength="1">
</cc1:AutoCompleteExtender>
{
SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
List<string> list = new List<string>(); foreach (DataRow row in ds.Tables[0].Rows)
{
string keyword = Convert.ToString(row["name"]);
list.Add(keyword);
} conn.Dispose();
conn.Close();
return list.ToArray();
}
主要是从这个页面读取的数据,然后填充到数组,是不是这里面写的不对呢?
用的是4.1版本的
public class GetKeywords : System.Web.Services.WebService
{ public GetKeywords()
{
} [WebMethod]
public string[] GetKeyword(string prefixText, int count)
{
SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
List<string> list = new List<string>();
foreach (DataRow row in ds.Tables[0].Rows)
{
string keyword = Convert.ToString(row["name"]);
list.Add(keyword);
} conn.Dispose();
conn.Close();
return list.ToArray();
}}
感觉没有错啊 帮忙看看 谢谢
/// <summary>
/// Summary description for Role
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GetKeywords : System.Web.Services.WebService
{
....
}
这玩意要加上滴
这两个也是在哪里呢?
是不是加的AJAX控件的问题呢?
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class GetKeywords : System.Web.Services.WebService { public GetKeywords () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class GetKeywords : System.Web.Services.WebService { public GetKeywords () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string[] HelloWorld()
{
return new string[1] { "Hello World" };
}
}引用中改一下:
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtKeyword" Enabled="True" ServicePath="~/Landing/GetKeywords.asmx"
ServiceMethod="HelloWorld" CompletionSetCount="7" MinimumPrefixLength="0">
</cc1:AutoCompleteExtender>
试试看
并且发布后也行 我的那个怎么就不行
{
SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
List<string> list = new List<string>();
foreach (DataRow row in ds.Tables[0].Rows)
{
string keyword = Convert.ToString(row["name"]);
list.Add(keyword);
} conn.Dispose();
conn.Close();
return list.ToArray();
}
catch(Exception ex)
{
return new string[1] { ex.ToString() };
}
如果运行过程中还遇到什么问题,可以联系我QQ:120283955