I am creating a web part in MOSS 2007 that contains an autocompleteextender.
I have ajax-enabled my site by adding all the configs in web.config (Example here)
My web service:
[System.Web.Script.Services.ScriptService]
public class AutoComplete : System.Web.Services.WebService
{
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)
{
List<string> results = new List<string>();
results.Add("Here");
results.Add("Here");
results.Add("Here");
results.Add("Here");
results.Add("Here");
results.Add("Here");
results.Add("Here");
return results.ToArray();
}
}
I am able to hit the web service from web browser. However, the autocompleteextender does not call my web service.
My web service url: http://[myserver]/AutoComplete.asmx (I used this for the ServicePath of the extender). My web part page: http://[myserver]/Pages/mypage.aspx
I also tried to add a calendarextender onto the page and the calendar renders underneath the textbox and shows as inline html. Weird.
Any thought would be helpful.
Thanks
From you web service url it looks like you've put the web service into the root folder of your site. This will not work as this folder is handled by the SharePoint VirtualPathProvider which will look up files in the content database.
You should put your web service into a subdirectory or either 12Hive\ISAPI or 12Hive\LAYOUTS and then call it through the corresponding
http://[myserver]/_vti_bin/[Folder]/AutoComplete.asmx
or
http://[myserver]/_layouts/[Folder]/AutoComplete.asmx
I can't understand why you need a web service if you use AJAX? you can just put the code inside of your web part (or whatever that is you build) and do a postback inside a update panel to fetch the values. Much easier to implement/install/debug/support.
Of course the previous answer is correct regarding the location of the web service. I just can add that the usual location would be _vti_bin and not layouts where you usually put your custom ASPX pages, but of course both technically would work.
Please keep in mind that you should also add a script manager to the page, using code or master page mark-up, otherwise it would not work, regardless whether you have the AJAX additions to the web.config or not