Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm having trouble with the autocomplete on the page. The setup is complicated:
FrameworkMasterPage
ApplicationMasterPage
MyContentPage

Initially, FrameworkMasterPage holds everything in asp:UpdatePanel, but I've tried removing it just to check, it doesn't work even without updatepanel.

I call PageMethod, with the following signature:
VB
<System.Web.Services.WebMethod()> _
   Public Shared Function GetPrimatelj(prefixText As String, count As Integer) As String()
     Dim tl As New List(Of String)
        tl.Add("one")
        tl.Add("two")
        tl.Add("onu") ' so I can check that "on" return two selections

        Return tl.ToArray
End Function


The method is executed successfully, but the result is full page rendering instead of method result. I get autocomplete dropdown, but it contains one under the other
D
o
c
t
y
p
e etc...whole page rendering letter by letter.

I've tried calling directly PageMethod proxy...same result. I've tried both AjaxToolkit AutoCompleteExtender (thus, the signature above) and jQuery Ajax call

Same result. Yes, I did autocomplete before, more then once :).

This is (base, there is more code due to cache handling, but this is the critical part) my ajax call

JavaScript
$.ajax({
                           url: "AjaxController.aspx/GetPrimatelj",
                           data: "{ 'term': '" + request.term + "' }",
                           dataType: "json",
                           type: "POST",
                           contentType: "application/json; charset=utf-8",
                           dataFilter: function (data) { return data; },
                           success: function (data) {
                               oldterm = request.term;
                               cache[request.term] = data.d;
                               response($.map(data.d, function (item) {
                                   return {
                                       value: item
                                   }
                               }))
                           },
                           error: function (result, status, error) {
                               console.log(status + " - " + error);
                           }
                       });


Help?
Posted
Updated 17-Nov-14 21:48pm
v2
Comments
Sinisa Hajnal 18-Nov-14 9:10am    
Anyone? I'm looking for inspiration, not necessarily full solution.

Can you share what you were trying to achieve here ? The Javascript URL seems like MVC pattern, But you have used Update panel that is part of legacy ASP web application.

Are you calling the .Ajax method from any of the Key press event. if so, if the function written on the same page , you need to have only function name , it does not required page name there.
In Chrome developer tool (F12) in the console you can see whether you getting 4XX Error or not. If not then your URL is fine.

Confirm this with by putting simple alter and let me know.

- Maheswaran.S
 
Share this answer
 
Comments
Sinisa Hajnal 19-Nov-14 8:27am    
I KNOW the code works. It works if I get it out in clean project and on empty page. Unfortunately, I'm stuck with ASP.NET 3.5, outside web service is not an option, MVC is not an option. I have to work with PageMethods. The problem is that everything gets called, it is just that the method returns full page HTML ready for rendering not just JSON.

I've written another question with clarifications, once I confirmed that everything works, but I am still at a loss why that doesn't work.

http://www.codeproject.com/Questions/844103/My-WebMethod-returns-full-HTML-of-the-page?arn=0

Thank you for your interest. I'm using jQuery autocomplete so probably using keypress internally. Test method is written on the same page, but in practice there will be one AjaxCalls page with webmethods in place of web service.
i got the issue. Your method should be an static.

http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/[^]

Refer the above link.

Regards,
Maheswaran.S
 
Share this answer
 
Comments
Sinisa Hajnal 21-Nov-14 7:02am    
Thank you, but no. It is set as static - Shared is VB.NET equivalent. Please don't try to solve this by newbie mistakes, I've tried most common ones and multiple versions of not so common mistakes :)

Thank you for trying though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900