[dba-VB] Initiating and monitoring long running ASP.NET 2.0 server side process...

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Fri Jun 6 01:08:37 CDT 2008


Hi All,

I need to do the following:

- start a long running (up to 1 minute) process on the ASP.NET 2.0
application server side by (e.g.) clicking ASP.NET web form's button;

- immediately get ASP.NET web form freed from waiting of this process
getting finished;

- but in the same time something like JavaScript script started on client
side sending, say, every second an XMLHTTP request to the ASP.NET server
side, and getting back the status of long running process and presenting it
on the client side - just in a textbox/label would be ok for starters...

The above (or similar) procedure can be done for sure I just need to know
ASAP how to do that as I haven't yet programmed something like that - a link
to a good sample on Internet would be good enough for me to study and to
make here my adapted custom solution....

Please note - I need ASP.NET 2.0 solution, without AJAX extension - just
using async callback feature if possible.

Async callback's simple sample is in the P.S. of this message but I need
more:

- where alert(...) is called in the below sample on client side there should
be a call to JavaScript periodically every 1 second sending XMLHTTP request
to the server...........???

Thank you.

--
Shamil

P.S.

<%@ Page Language="C#" Title="Fun with callbacks: a simple one" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
<script runat="server">
    private string returnValue;
    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    {
        try
        {
            //Page.ClientScript.ValidateEvent("OnCallback");
            returnValue = "Hello, " +
                    eventArgument +
                    ". Your name is " +
                    eventArgument.Length.ToString() +
                    " characters long.";
        }
        catch
        {
            // Failed callback validation logic.
        }
    }  
    
     string ICallbackEventHandler.GetCallbackResult() 
     {
         return returnValue;
     }

    protected override void Render(HtmlTextWriter writer)
    {
        Page.ClientScript.RegisterForEventValidation("OnCallback");
        base.Render(writer);
    }

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head id="Head1" runat="server">
  <title>Asycn Callback sample</title>
  </head> 
  <script type ="text/ecmascript" >
  function OnCallback(result, context) {
    alert(result);
  }
  </script>
  <body>
    <form id="Form1" runat="server">
      Enter your name here:
      <input name="name" />
      <input type="button" id="CallbackBtn" value="Send"
        onclick="<%= ClientScript.GetCallbackEventReference(
          this,
          "document.forms[0].name.value", 
          "OnCallback", 
          "this", 
          "OnCallback", 
          true) %>" />
    </form>
  </body>
</html>




More information about the dba-VB mailing list