I'm new here, so sorry if I'm making some mistake with the post...
I'm trying to use angularjs with ASP.NET Web Forms, and everything was going well until I need to make a request to the c# webmethods. I searched here and on other pages for the solution and didnt found anything.
Let's go to te problem: My request just return my Default.aspx html code, and not my JSON. In fact, my request doesn't call my webmethod...
app.controller('CtrlBoletos',function($scope, FactoryBoleto) {
$scope.selections = [];
$scope.boletos = FactoryBoleto.getBoletos();
$scope.gridBoletos = {
data: 'boletos',
selectedItems: $scope.selections,
multiSelect: false
};
});
app.factory('FactoryBoleto', function ($http) {
var getBoletos = function() {
$http({
method: 'POST',
url: "./Default.aspx/get_boleto",
async: false
}).success(function(result){
console.info(result);
});
};
return { getBoletos: getBoletos };
});
and this is my webmethod
[WebMethod]
public static string get_boleto()
{
List<TFechamento_Boleto> lista = new List<TFechamento_Boleto>();
JavaScriptSerializer serializer =new JavaScriptSerializer();
TFechamento fechamento = new TFechamento(2);
lista = fechamento.getDados(1).Boleto;
var json = serializer.Serialize(lista);
return json;
}
Ah, and if i make the request with JQuery AJAX I get the json...
someone help me, im getting crazy with this... and sorry for my bad english :p