0
Answer

Can't get AutoComplete to work

Photo of Ross

Ross

15y
3k
1
I followed this tutorial to the letter and can't get it to work.  Here's what I have:

Default.aspx:

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
TargetControlID="TextBox1" ServicePath="~/WebService.asmx" ServiceMethod="GetComponents" MinimumPrefixLength="1" EnableCaching="true" Enabled="true" CompletionSetCount="10">
</asp:AutoCompleteExtender>

</div>
</form>
</body>
</html>



WebService.asmx.cs file:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WebApplication1
{
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{

[WebMethod]
public string[] GetComponents(string prefixText, int count)
{
string[] result = new string[5];
result[0] = "Hello";
result[1] = "Hi";
result[2] = "Greetings";
result[3] = "Salutations";
result[4] = "Bonjour";
return result;
}
}
}



I also have a zip of the solution here: http://acm.uwec.edu/~benderrr/WebApplication1.zip

Edit:  I forgot to add that I am able to run the WebService by itself.  It returns the values from the function.  The function is never invoked from the aspx though.

Any help would be great, thanks!

Answers (0)