<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { $("#TextBox1").keyup(function () { var input = $(this).val(); alert(input); $.ajax({ type: "POST", url: "AutoCompleteWithJQueryAndjson.aspx/AutoComplate", data: "{'args': '" + input + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (output) { $("#<%=Label1.ClientID%>").html(output.d); } }); }); }); </script></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form></body></html>
[System.Web.Services.WebMethod(Description = "Per session Hit Counter", EnableSession = true)]public static string AutoComplate(string args){ // code goes here... //retrun statement}