基于webmethods结果回发页面

时间:2011-07-26 09:37:27

标签: javascript asp.net postback webmethod

如何根据WebMethod的结果发回页面?

 function AssignmentConditionsSaveAS_Clicked() {

        var txtConditionName = $('input[id$="txtConditionName"]').val();
        PageMethods.IsExistsSavedCondition(txtConditionName, OnSuccess, OnFailure);
        return false;
    }

    function OnSuccess(result) {
        if (result == 'true') {
            if (confirm('A saved condition with that name already exists. Do you want to overwrite?')) {
                return true;
                // I want to post back the clicked button
                // Can not use __dopostback, because its a control inside a user control                    
            }
            else {
                return false;
            }
        }
        else if (result == 'false') {
            alert('Not Exist');
        }
    }

    function OnFailure(error) {
        alert(error);
    }

OR

我该如何做这样的事情:

__doPostBack($('input[id$="btnSaveAS"]'), '');

2 个答案:

答案 0 :(得分:1)

你必须这样做

__doPostBack($('input[id$="btnSaveAS"]').attr('name'), '');

答案 1 :(得分:0)