WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
c# code:
namespace WebApp
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static List<string> GetAutoCompleteData(string username)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=Bas; Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand("select DISTINCT name from Persons where name LIKE '%'+@SearchText+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", username);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["name"].ToString());
}
return result;
}
}
}
I think Sohail also can help me. . . PLEASE HELP ME TO FINISH THIS TASK.
The mistake is:
Server mistake in application '/'.
Unknown Web method GetAutoCompleteData.
Name of parametr: methodName
Описание: Необработанное
исключение при выполнении текущего веб-запроса. Изучите трассировку стека для получения дополнительных сведений о данной ошибке и о вызвавшем ее фрагменте кода.
Сведения об исключении: System.ArgumentException: Неизвестный веб-метод GetAutoCompleteData.
Имя параметра: methodName
Ошибка источника:
Необработанное исключение при выполнении текущего веб-запроса. Информацию о происхождении и месте возникновения исключения можно получить, используя следующую трассировку стека исключений.
Трассировка стека:
[ArgumentException: Unknown web method GetAutoCompleteData.
Name of parametr: methodName]
System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) +488143
System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) +164
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Информация о версии: Платформа Microsoft .NET Framework, версия:4.0.30319; ASP.NET, версия:4.0.30319.17929
I think that the problem is here:
...
using (SqlCommand cmd = new SqlCommand("select * from Basic where(column1 LIKE '" +
username + '%' + "')", con))
{ cmd.Parameters.AddWithValue("@username", username);
shamson
Member
19 Points
88 Posts
WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 09:02 AM|LINK
WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
c# code:
namespace WebApp
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static List<string> GetAutoCompleteData(string username)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=Bas; Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand("select DISTINCT name from Persons where name LIKE '%'+@SearchText+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", username);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["name"].ToString());
}
return result;
}
}
}
}
}
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="ExpBasEngDicWEB.WebForm2" %>
<!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 id="Head1" runat="server">
<title>AutoComplete Box with jQuery</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function(request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Webform2.aspx/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function(data) {
response(data.d);
},
error: function(result) {
alert("Error");
}
});
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<div class="ui-widget">
<label for="tbAuto">Enter UserName: </label>
<input type="text" id="txtSearch" class="autosuggest" />
<br />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
</div>
</div>
<p>
</p>
</form>
</body>
</html>
mistake is "Error"
THANKS TO EVERYONE!
furry
Member
584 Points
108 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 09:35 AM|LINK
provided information is not enough to find the exact problem
my first suggestion is to add [WebMethod] above method GetAutoCompleteData(), like below
[WebMethod] public static List<string> GetAutoCompleteData(string username) { }if it didn't workout, please change error listner to
error: function(result) { alert(result.responseText); }and let us know the error you receive.
SohailShaikh
Contributor
6129 Points
1172 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 09:38 AM|LINK
mistake 1 set method as web method
mistake 2 where is parametter your method receive a method but you are not provide on ajax call
now if you want auto complete then you can download from given link program name is =AutoCompletejQueryASP
https://skydrive.live.com/#cid=2F22272220E37707&id=2F22272220E37707%21103
Sohail Shaikh
Sujeet Saste
Contributor
2998 Points
572 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 09:54 AM|LINK
Declare GetAutoCompleteData as [WebMethod] include namespace System.Web.Services;
Then also if it not works, then provide User ID and Password to your SqlConnection.
Hope it helps.
Mark my post as answer if it helps you
Do FEAR (Face Everything And Rise)
Please mark as Answer if my post helps you..!
My Blog
shamson
Member
19 Points
88 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 02:18 PM|LINK
Hi dear furry
Did you tried this? Can you solv this problem? Even with your method!
This problem torment me 3 days !!!
PLEASE HELP!
furry
Member
584 Points
108 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 04:22 PM|LINK
yeah, i've tried and its working for me.
i just changed below lines
[System.Web.Services.WebMethod] public static List<string> GetAutoCompleteData(string username) { //Your Code }in Javascript please change the below lines
error: function(result) { $('body').append("<div />").html(result.responseText); }so if there is anyother error, we'll know.
shamson
Member
19 Points
88 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 24, 2012 04:50 PM|LINK
Hello dear Mr. Furry and Mr. Sohail
I think Sohail also can help me. . . PLEASE HELP ME TO FINISH THIS TASK.
The mistake is:
Server mistake in application '/'.
Unknown Web method GetAutoCompleteData.
Name of parametr: methodName
Описание: Необработанное исключение при выполнении текущего веб-запроса. Изучите трассировку стека для получения дополнительных сведений о данной ошибке и о вызвавшем ее фрагменте кода.
Сведения об исключении: System.ArgumentException: Неизвестный веб-метод GetAutoCompleteData.
Имя параметра: methodName
Ошибка источника:
Трассировка стека:
Информация о версии: Платформа Microsoft .NET Framework, версия:4.0.30319; ASP.NET, версия:4.0.30319.17929
I think that the problem is here:
...
using (SqlCommand cmd = new SqlCommand("select * from Basic where(column1 LIKE '" + username + '%' + "')", con))
{
cmd.Parameters.AddWithValue("@username", username);
...
SohailShaikh
Contributor
6129 Points
1172 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 25, 2012 08:26 AM|LINK
hey just download the demo program from my above givien link through this you can understand how auto complete work
Sohail Shaikh
shamson
Member
19 Points
88 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 25, 2012 08:48 AM|LINK
Hello dear SohailShaikh
Your sample says a lot of mistakes.
Can you try my sample or another sample to solve this my MAIN PROBLEM.
I know that you easily can solve my problem!!! Please help me.
I'm using visual studio 2010 c#.
THANKS for you help!!!
SohailShaikh
Contributor
6129 Points
1172 Posts
Re: WHERE IS THE PROBLEM??? PLEASE HELP ME??? WHAT PLACE TO CHANGE???
Dec 25, 2012 09:02 AM|LINK
you want jquery autocomplete ? if yes then i will create and provide you
Sohail Shaikh