3

I m trying a auto complete functionality for a textbox , where I am sending a get request to a webmethod which is returning complete page content rather than actual data as shown below.

enter image description here

i am using following C# code, while my all other methods with Post request are working fine

[WebMethod]
        [ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]
        public static string GetListOfUsers()
        {
            return "{'0701414001','0701414002'}";
        }
Abhi
  • 5,501
  • 17
  • 78
  • 133

2 Answers2

0

I think the problem is in your parameters: you're calling Email.aspx/GetListOfUusers?query=lkkjlk but your public static string GetListOfUsers() does not contain a parameter name.

Try changing to this:

public static string GetListOfUsers(string query)
{
...
}

I'd also try removing this: ResponseFormat=ResponseFormat.Json and see if it changes anything.

frenchie
  • 51,731
  • 109
  • 304
  • 510
  • no adding parameters also doesn't results in desired results , also tried by removing ResponseFormat=ResponseFormat.Json – Abhi May 28 '12 at 07:24
  • 2
    Take look at an answer I provided here: http://stackoverflow.com/questions/8405458/return-json-data-from-asmx-web-service/ I used page methods too but then I switched to web services and it's much much easier. – frenchie May 28 '12 at 17:02
0

I think this can be achieved in the following most simple way as mentioned over here in this article by creating ashx handler http://codeasp.net/articles/asp-net/212/using-jquery-autocomplete-in-asp-net

Article Demo http://codeasp.net/assets/demos/articles/using-jquery-autocomplete-in-asp-net/using-jquery-autocomplete-in-asp-net-multiple.aspx

Abhi
  • 5,501
  • 17
  • 78
  • 133