views:

21

answers:

1

I have the following JavaScript snippet:

<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(ajaxBeginRequest);
    prm.add_endRequest(ajaxEndRequest);

    function ajaxBeginRequest(sender, args) {
        $.blockUI({ message: '<h1><img src="/images/ajax_loading.gif" /> <%= MyNameSpace.SomeWhereElse.Shared.RandomLoadingMessage() %></h1>' });
    }

    function ajaxEndRequest(sender, args) {
        $.unblockUI();
    }
</script>

Right now the C# line runs at page load and gives me one random message, but it is constant through the page execution until the page is refreshed. What I'd like it to do is give me a different message on each ajax Request

Any suggestions for this?

A: 

You can make a ajax call to a web service (called script service) to get the message on each invocation. See this article where it explains how to call script services using ASP.NET generated proxies as well as using jquery methods. You can use either method.

VinayC