ITsolutionWizard
asked on
asp.net jquery
I have below codes working fine with dropdown. but auto complete does not work.
It shows 'internal object error' which I don't know what it is. Anyone can help? You can copy/paste the code to your visual studio and it will show when you type something inside of the textbox.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. cs" Inherits="WebApplication6. WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></ti tle>
<link rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList runat="server" ID="dropDown"></asp:DropDo wnList>
<br /><br />
<asp:TextBox runat="server" ID="txtCity"></asp:TextBox >
</form>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$("#txtCity").autocomplete ({
source: function (request, response) {
var param = { cityName: $('#txtCity').val() };
$.ajax({
url: "Default.aspx/GetProductLi stByKeywor d",
data: JSON.stringify(param),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus + ' ' + errorThrown + ' ' + XMLHttpRequest.toString()) ;
}
});
},
minLength: 1//minLength as 2, it means when ever user enter 2 character in TextBox the AutoComplete method will fire and get its source data.
});
});
</script>
</body>
</html>
'''''''''''''''''''''''''' '''''''''' '''''''''' '''''''''' '''''''''' '''
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data;
using System.Configuration;
using System.Web.Services;
namespace WebApplication6
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<string> GetProductListByKeyword(st ring keyword)
{
try
{
List<string> brandNames = new List<string>();
brandNames.Add("apple");
brandNames.Add("orange");
brandNames.Add("manago");
return brandNames;
}
catch (Exception ex)
{
throw new ApplicationException("Some thing wrong in the query/database connection: ", ex);
}
}
}
}
It shows 'internal object error' which I don't know what it is. Anyone can help? You can copy/paste the code to your visual studio and it will show when you type something inside of the textbox.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></ti
<link rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList runat="server" ID="dropDown"></asp:DropDo
<br /><br />
<asp:TextBox runat="server" ID="txtCity"></asp:TextBox
</form>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$("#txtCity").autocomplete
source: function (request, response) {
var param = { cityName: $('#txtCity').val() };
$.ajax({
url: "Default.aspx/GetProductLi
data: JSON.stringify(param),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus + ' ' + errorThrown + ' ' + XMLHttpRequest.toString())
}
});
},
minLength: 1//minLength as 2, it means when ever user enter 2 character in TextBox the AutoComplete method will fire and get its source data.
});
});
</script>
</body>
</html>
''''''''''''''''''''''''''
using System;
using System.Collections.Generic
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data;
using System.Configuration;
using System.Web.Services;
namespace WebApplication6
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<string> GetProductListByKeyword(st
{
try
{
List<string> brandNames = new List<string>();
brandNames.Add("apple");
brandNames.Add("orange");
brandNames.Add("manago");
return brandNames;
}
catch (Exception ex)
{
throw new ApplicationException("Some
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Out of my desk, I don't have VS currently, if you can publish your code to internet, I can help.
Which results do get when calling the web method directly? Could you post it?
Which results do get when calling the web method directly? Could you post it?
ASKER
codes already on the web here. if you can not do it, it is okay.
ASKER