开发者

ASP.NET PageMethod failed. How to know why?

When I try to access a PageMethod within javascript code it always is 开发者_高级运维unsuccessfull. I use get_message() in onfailed method but no relevant informations is displayed. I'd like to get what's the actual problem. I have a jquery popup with two buttons. When Guardar button is pressed I need that the pagemethod "GuardaComentario" (SaveComment) is executed. This is my code:

$(document).ready(function () {
// Dialogo      
$('#dialog').dialog({
    autoOpen: false,
    resizable: false,
    modal: true,
    width: 450,
    buttons: {
        "Guardar": function () {
            $(this).dialog("close");
            // Llamada ajax para guardar el comentario
            PageMethods.GuardaComentario(onSucceed, onFailed);
        },
        "Cancelar": function () {
            $(this).dialog("close");
        }
    }
});

// Dialogo Link
$('#dialog_link').click(function () {
    $('#dialog').dialog('open');
    return false;
});

});

function onSucceed(res, destCtrl) { alert("OK"); }
function onFailed(res, destCtrl) { alert(res.get_message()); }

Thank you!!


Reasons for failure can be anything - for example, java-script proxies for PageMethods are not generated, there are issue in configuration files and there fore PageMethod calls are not routed correctly etc. You have to investigate them one by one. Are there any java-script errors - check tools such as FireBug in FireFox (other browsers have similar tools) to check for script issue. If there are no script issue then you should inspect request/response - use tool such Fiddler (or Firebug) see what request being fired to server and server's response to it. Lastly, you can debug your app and put a break-point in your PageMethod code to see if request reaches to there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜