<script src="../ui/jquery-1.4.2.js" type="text/javascript"></script>
<script src="../ui/jquery.ui.core.js" type="text/javascript"></script>
<script src="../ui/jquery.ui.widget.js" type="text/javascript"></script>
<script src="../ui/jquery.ui.position.js" type="text/javascript"></script>
<script src="../ui/jquery.ui.autocomplete.js" type="text/javascript"></script>
<script language ="javascript">
$(function() {
$("#txtEstateName").autocomplete({
source:function(request, response) {
$.ajax({
url:"frmHouseData.aspx?RsName="+escape($("#txtEstateName").val())+"&Date=" + new Date(),
dataType: "json",
data: request,
success: function(data) {
response(data);
}
});
}
});
});</script>"><input type="text" id="txtEstateName"/>
代理页面frmHouseData.aspx源码如下:
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
this.Response.Write(GetDataList());
this.Response.End();
}
}
protected string GetEstateList()
{
string JsonStr=string.Empty;
string EstName=this.Server.UrlDecode(this.Request.QueryString["RsName"]);
string SqlStr = "select EstateName from t_Estate where charindex('"+EstName+"',EstateName)>0";
SqlDataReader myDR = this.DataManager.selectReader(SqlStr);
while (myDR.Read())
{
JsonStr += "\""+myDR["EstateName"].ToString().Replace("\r","").Replace("\n","")+"\",";
}
if(RsName!=string.Empty)
{
JsonStr=JsonStr.Remove(RsName.Length-1,1);
}
myDR.Close();
return "["+JsonStr+"]";
}