C# pagemethod autocomplete Materialize error

Asked

Viewed 73 times

1

I cannot execute my c# function through the materialize framework autocomplete. It does not execute and returns no errors. With bootstrap it works.

I’m using Asp.net without codebehind, all in the same file.

I can call the function by Chrome console, but not autocomplete.

javascript call:

$('#autocomplete-input').autocomplete({
  data: function (request,response){
    PageMethods.GetAllSavedAddress("nextel", function (datax) {
      console.log("teste"); //ESSA LINHA TERIA QUE FUNCIONAR INDEPENDENTE DO RETORNO DO METODO
    return response(datax);
    })
  },
  limit: 20,
  onAutocomplete: function(val) {
    console.log(val);
  },
  minLength: 1,
});

I put a console.log right after the pagemethod call, but even that doesn’t work.

I created a JS function to call through the console and works perfectly:

 function TesteX() {
            PageMethods.GetAllSavedAddress($('#autocomplete-input').val(), onSucess, onError);
            function onSucess(result) {
                   alert(result);
            }
            function onError(result) {
                console.log('Something wrong.');
            }
        }

I know the error is in this part because if I popular in the hand works. Example:

$('input.autocomplete').autocomplete({
    data: {
      "Apple": null,
      "Microsoft": null,
      "Google": null
    },
    limit: 20, 
    onAutocomplete: function(val) {
      // Callback function when value is autcompleted.
    },
    minLength: 1, 
  });

Help super welcome, rs.

  • What is PageMethods.GetAllSavedAddress?

  • Where has C# in your question?

  • Pagemethods is a member of System.Web.UI.

  • Getallsavedaddress is a Static Web Method C# I created. It returns a json. In Jquery UI it works, but not materialize

  • That’s what I was wondering. This Javascript is in a right Razor view? See the result of the rendering in the browser and add in your question, PF.

  • No. It’s a Webform. And it doesn’t return any errors, it just doesn’t execute

  • See the rendering result and put here

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.