0

我有一个 USercontrol UMessages.ascx 我有功能将消息显示为

    function ShowSuccess(Message) {
            alert(" ShowSuccess");
            $(".litMessage").text(Message);
            $(".MessageBox").class("success");
            $(".MessageBox").show();
        }

我有 Default.aspx 页面,其中我使用 Ajax 调用来更新值,更新后我只想显示 User Control.ie ShowSuccess 中的消息

我如何在 Jquery 或 WebMethod 中使用这个 ShowSuccess ..?

4

1 回答 1

0

你必须使用网络方法

[System.Web.Services.WebMethod]
 function ShowSuccess(Message) {
        alert(" ShowSuccess");
        $(".litMessage").text(Message);
        $(".MessageBox").class("success");
        $(".MessageBox").show();
    }

并在 aspx 页面中编写此 jquery 函数

function callPageMthodWithjQueryAjax() {
        jQuery.ajax({
            url: '/Default.aspx/ShowSuccess',
            type: 'post',
            contentType: 'application/json',
            data: JSON.stringify({ argument: argument }),
            dataType: 'json',
            processData: false,
            success: function (data, textStatus) {
                jQuery('#result').html(data.d);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var jsonError = JSON.parse(XMLHttpRequest.responseText);
                alert(jsonError.Message);
            }

        });
    }
于 2013-06-01T06:31:07.207 回答