Trouble using AutoCompleteExtender

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

VS2008

I have trouble getting the AutoCompleteExtender to work. I've seen the video
at
http://www.asp.net:80/learn/ajax-videos/video-122.aspx but don't understand
what I do wrong. I've even downloaded the source code next to the video and
cannot see what I do wrong here. When I run the .aspx webpage, I start
typing in the textbox but isn't called after I've typed in 3 chars. I know
that method isn't called as I've set a breakpoint in the start of the
GetCompletionList method.

In my datasource there is a name with the pattern "uuu", so if I start
typing "uuu" atleast that name shold be displayed...

*** markup in my .aspx webpage *****************
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/Services/AutoCompleteName.asmx" />
</Services>
</asp:ScriptManager>

Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtName"
ServicePath="~/Services/AutoCompleteName.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="3" CompletionSetCount="10" >
</ajaxToolkit:AutoCompleteExtender>

******* ****************

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 AutoCompleteName : System.Web.Services.WebService {

public AutoCompleteName () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
List<Name> nameCollection = Name.GetNames(prefixText, count);
List<string> names = null;
foreach (Name name in nameCollection)
{
names.Add(name.surename);
}
return names.ToArray();
}

}

could it be caused by this: ServicePath="~/Services/AutoCompleteName.asmx"
in the video source code it is ServicePath="AutoCompleteName.asmx", but I've
created a subfolder for my .asmx files just in case my project will have
more .asmx files. I thought it was a nice way of keeping the project tidy,
not having everything in the root folder.....

any suggestions?
 
Jeff said:
hi

VS2008

I have trouble getting the AutoCompleteExtender to work. I've seen the
video at
http://www.asp.net:80/learn/ajax-videos/video-122.aspx but don't
understand what I do wrong. I've even downloaded the source code next to
the video and cannot see what I do wrong here. When I run the .aspx
webpage, I start typing in the textbox but isn't called after I've typed
in 3 chars. I know that method isn't called as I've set a breakpoint in
the start of the GetCompletionList method.

In my datasource there is a name with the pattern "uuu", so if I start
typing "uuu" atleast that name shold be displayed...

*** markup in my .aspx webpage *****************
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/Services/AutoCompleteName.asmx" />
</Services>
</asp:ScriptManager>

Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtName"
ServicePath="~/Services/AutoCompleteName.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="3" CompletionSetCount="10" >
</ajaxToolkit:AutoCompleteExtender>

******* ****************

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 AutoCompleteName : System.Web.Services.WebService {

public AutoCompleteName () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
List<Name> nameCollection = Name.GetNames(prefixText, count);
List<string> names = null;
foreach (Name name in nameCollection)
{
names.Add(name.surename);
}
return names.ToArray();
}

}

could it be caused by this: ServicePath="~/Services/AutoCompleteName.asmx"
in the video source code it is ServicePath="AutoCompleteName.asmx", but
I've created a subfolder for my .asmx files just in case my project will
have more .asmx files. I thought it was a nice way of keeping the project
tidy, not having everything in the root folder.....

any suggestions?
Don't you need to uncomment the ScriptService attribute?
 
Back
Top