views:

117

answers:

2

Hi guys,

Let's say that in the HTML with the help of an UpdatePanel I have the "loading" animated gif running while ASP.NET is processing data from a webservice.

I'm just wondering if there is a way to implement an Event in the .NET code that can be listen from the HTML code, like:

I'm requesting Persons data from a WebService, one by one, and I wanted to the loading text in the HTML side shows.

Importing person 1
Importing Person 2
Importing Person 3
All Done!

and out

Is there any trick to do this?

right now I have this in my HTML Code

the HEAD part

<script type="text/JavaScript" language="JavaScript">

    function pageLoad() {

        try {
            var manager = Sys.WebForms.PageRequestManager.getInstance();
            manager.add_endRequest(endRequest);
            manager.add_beginRequest(OnBeginRequest);
            manager
        }
        catch (err) {
        }
    }

    function OnBeginRequest(sender, args) {

        $("#loadingText").html("<img src='_assets/img/animated/parweb_loading.gif' alt='' />&nbsp;" + strLoadingText);
    }

    function endRequest(sender, args) {
    }  

</script>

the BODY parts has:

<asp:UpdateProgress AssociatedUpdatePanelID="pnlAllIn" runat="server" ID="pnlUpdating">
    <ProgressTemplate>
        <div id="loadingText" style="background-color: Red; position: absolute; width: 200px;
            top: 0px; right: 20px; padding: 5px; color: White; text-align: center; vertical-align: middle;
            font-size: 14px;">
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>

Thank you for the help.

A: 

Could you not use AJAX to do this. Fire off your query of the webservice on a separate thread. The thread should keep an instance of a variable (or reference to one) that tracks the progress from the webservice. The javascript could then make a call every 2 seconds to get the status and then update your HTML accordingly.

uriDium
+1  A: 

Microsoft's AJAX.NET is an upper level controls so it's easy to use but you are a little bit limited.

With Michael Schwarz's AJAX.NET library, you can do it in this way :

  1. Write a method to do importing information. This method will write a log to session or somewhere else.

  2. Write a second method to check this log and print while the operation continues.

Canavar