views:

37

answers:

2

Hi Guys,

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

A: 

Hi madatanic

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 
Per Jakobsen
I tried it in the _layouts folder as well, but it still won't call my web service.
madatanic
Have you tried just to browse to http://[myserver]/_layouts/[Folder]/AutoComplete.asmx?If that works try using Fiddler (www.fiddler2.com) to see what goes on.If only one request goes through then you should look for "SharePoint Panel Fix"
Per Jakobsen
I was able to browse my web service inside _layouts folder. I also have the UpdatePanel fix inside my web part. It seems like there's a SharePoint functionality that overrides the Ajax. I am not sure what though.
madatanic
A: 

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

Vladi Gubler
I have scriptmanager on the page, even add a service reference to it.
madatanic
Consider not using the web service. Can you confirm that the server side code runs on AJAX submit?
Vladi Gubler
I am not sure which server side code you're talking about. However, to explain the reason why i used web service, the autocompleteextender fetches the suggestions by using either a page method or a web service. There's not a way, that i know of, to create a static page method inside a web part. Web service is the solution that's left. If by server side code you meant the part of adding that extender to the web part's controls, then yes, it ran and added the extender to the page.
madatanic