本文介绍了ajax自动完全控制不起作用我正在使用VISUAL STUDIO 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:TextBox ID="txtAreaName" runat="server" CssClass="txtArea" placeholder="Enter Area to Search Dealers" Height="34px" Width="259px" onkeypress="searchKeyPress(event);" onKeyUp="Complete1(this, event);"></asp:TextBox>
<asp:autocompleteextender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtAreaName"
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="500" ServiceMethod="GetCountries" > </asp:autocompleteextender>
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCountries(string prefixText)
{
string a = prefixText.Trim();
OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["conStr"].ToString());
con.Open();
string query = " select distinct location from PROPERTY_INFORMATION_TABLE where upper(property_information_table.location)like '%" + a.ToString() + "%' or lower(property_information_table.location)like '%" + a.ToString() + "%'";
OracleCommand cmd = new OracleCommand(query, con);
OracleDataReader dr = cmd.ExecuteReader();
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
List<string> location = new List<string>();
while (dr.Read())
{
location.Add(dr["location"].ToString());
}
//for (int i = 0; i < dt.Rows.Count; i++)
//{
// location.Add(dt.Rows[i].ToString());
//}
return location;
}
这是我的webconfig
this is my webconfig
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="conStr" connectionString="user id=RealEstate;password=RealEstate;data source=xe;"/>
<add name="ConnectionString" connectionString="Data Source=xe;Persist Security Info=True;User ID=RealEstate;Password=RealEstate;Unicode=True" providerName="System.Data.OracleClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" batch="false">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="none"/>
</appSettings>
</configuration>
推荐答案
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static List<string> GetCountries(string prefixText)
更多详细信息请点击以下链接:
[]
这篇关于ajax自动完全控制不起作用我正在使用VISUAL STUDIO 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!