Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > progress bar status

Reply
Thread Tools

progress bar status

 
 
CT
Guest
Posts: n/a
 
      09-27-2006
Dear All,
Is there any to show progress status of all activities like database retrieval, navigation from one page to another page? I am looking for some source code to integrated in my .net application.

Any help is very much appreciated.

Thank you
CT
 
Reply With Quote
 
 
 
 
Laurent Bugnion
Guest
Posts: n/a
 
      09-27-2006
Hi,

CT wrote:
> Dear All,
> Is there any to show progress status of all activities like database retrieval, navigation from one page to another page? I am looking for some source code to integrated in my .net application.
>
> Any help is very much appreciated.
>
> Thank you
> CT


To display server-side activity progress on the web client witout
periodically refreshing the page, you need to use AJAX.

Here is a previous post I made in that newsgroup:

The simplest implementation of AJAX in .NET is using ASHX Custom
HttpHandlers. It's very simple: In your web site or web application
project, Add New Item / Generic handler.

Then, in the code behind, implement the methods (Studio 2005 gives you a
template).

From the client, use JavaScript and XmlHttpRequest to send the request
and read the response. There are many tutorial online.

Example for a simple asynchronous request:

var oHttp = null;
if ( window.XMLHttpRequest )
{
oHttp = new window.XMLHttpRequest();
}
else
{
if ( window.ActiveXObject )
{
oHttp = new window.ActiveXObject( "Microsoft.XMLHTTP" );
}
else
{
throw "UNSUPPORTED PLATFORM";
}
}
if ( !oHttp )
{
throw "Cannot create XmlHttpRequest";
}

var strQuery = "?param1=value1&param2=value2";
oHttp.open( "GET",
"myHandler.ashx" + strQuery,
true ); // true = async, false = sync

oHttp.onreadystatechange = function()
{
if ( oHttp.readyState == 4 )
{
oHttp = null;
fnCallback( oHttp );
}
}

oHttp.send( null );

Code behind:

In ProcessRequest, use the "context" parameter to extract the
QueryString, and then you can process according to the parameters.

For the Response, if you want to send XML code back, make sure to set
context.Response.ContentType = "text/xml; charset=utf-8";

To save an XML document to the response, use
docResponse.Save(
new XmlTextWriter( context.Response.OutputStream,
context.Request.ContentEncoding ) );

In the JavaScript, the XML code will be available in oHttp.responseXML.
The response is also available in plain text in oHttp.responseText. Also
check the oHttp.status, which contains status like 200 (OK), 500 (Server
error), etc...

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      09-27-2006

"Laurent Bugnion" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> CT wrote:
> > Dear All,
> > Is there any to show progress status of all activities like

database retrieval, navigation from one page to another page? I am looking
for some source code to integrated in my .net application.
> >
> > Any help is very much appreciated.
> >
> > Thank you
> > CT

>
> To display server-side activity progress on the web client witout
> periodically refreshing the page, you need to use AJAX.
>


Why? More specifically why is a asynchronous request needed?

A window.timeout to periodically kick off a request for progess info should
be sufficient there's no real need to make the request itself asynchronous
that I can see.

> Here is a previous post I made in that newsgroup:
>
> The simplest implementation of AJAX in .NET is using ASHX Custom
> HttpHandlers. It's very simple: In your web site or web application
> project, Add New Item / Generic handler.
>
> Then, in the code behind, implement the methods (Studio 2005 gives you a
> template).
>
> From the client, use JavaScript and XmlHttpRequest to send the request
> and read the response. There are many tutorial online.
>
> Example for a simple asynchronous request:
>
> var oHttp = null;
> if ( window.XMLHttpRequest )
> {
> oHttp = new window.XMLHttpRequest();
> }
> else
> {
> if ( window.ActiveXObject )
> {
> oHttp = new window.ActiveXObject( "Microsoft.XMLHTTP" );
> }
> else
> {
> throw "UNSUPPORTED PLATFORM";
> }
> }
> if ( !oHttp )
> {
> throw "Cannot create XmlHttpRequest";
> }
>
> var strQuery = "?param1=value1&param2=value2";
> oHttp.open( "GET",
> "myHandler.ashx" + strQuery,
> true ); // true = async, false = sync
>
> oHttp.onreadystatechange = function()
> {
> if ( oHttp.readyState == 4 )
> {
> oHttp = null;
> fnCallback( oHttp );
> }
> }
>
> oHttp.send( null );
>
> Code behind:
>
> In ProcessRequest, use the "context" parameter to extract the
> QueryString, and then you can process according to the parameters.
>
> For the Response, if you want to send XML code back, make sure to set
> context.Response.ContentType = "text/xml; charset=utf-8";
>
> To save an XML document to the response, use
> docResponse.Save(
> new XmlTextWriter( context.Response.OutputStream,
> context.Request.ContentEncoding ) );
>
> In the JavaScript, the XML code will be available in oHttp.responseXML.
> The response is also available in plain text in oHttp.responseText. Also
> check the oHttp.status, which contains status like 200 (OK), 500 (Server
> error), etc...
>
> HTH,
> Laurent
> --
> Laurent Bugnion, GalaSoft
> Software engineering: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch



 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      09-27-2006
Hi,

Anthony Jones wrote:

> Why? More specifically why is a asynchronous request needed?
>
> A window.timeout to periodically kick off a request for progess info should
> be sufficient there's no real need to make the request itself asynchronous
> that I can see.


In theory you're right. In praxis, however, I recommend against
synchronous XmlHttpRequest calls. If you send a synchronous request, the
whole JavaScript engine is blocked until the response arrives on the
client. It means that no animation, no other requests, no other
background activity will run as long as the response doesn't arrive.
Since we're on the web, it may take some time.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
disable title bar, status bar, and address bar of a window Matt HTML 9 08-23-2004 07:49 PM
javascript to disable the title bar, status bar, and address bar of a window Matt Javascript 9 08-23-2004 01:23 PM
Re: disable title bar, status bar, and address bar of a browser window John Hann ASP .Net 0 08-21-2004 05:07 AM
disable title bar, status bar, and address bar of a browser window Matt ASP .Net 0 08-21-2004 03:50 AM
Progress bar to show the progress of a task Charlie Zhang Java 3 08-16-2004 05:53 PM



Advertisments