Reload Page Command

A

Alan Z. Scharf

1. I have a chain of six asynch callbacks initiated by a button, and want
the page to refresh at the end of each callback to display

A. Results of a SQLServer query showing cumulative running time, and
B. A progress bar.

2. I have this working with a refresh timer:

<META http-equiv="refresh" content="5">

3. However, the blinking of page reloads is annoying, and I'd prefer to have
the page reload at exactly the end of each callback EndInvoke.

What is the command to force page reload in C#?

4. One of my HandleCompletions is below, with the place indicated where I
want to reload the page.

Thanks for any help.

Alan

private void HandleUpdateCapitalCompletion(IAsyncResult asyncResult)

{

try

{

// Retrieve Update delegate object

UpdateCapitalDelegate updateCapital = (UpdateCapitalDelegate)
asyncResult.AsyncState;

//Call EndInvoke to get result of UpdateCapital

string updateCapitalResult = updateCapital.EndInvoke(asyncResult);

//*** RELOAD THE PAGE HERE ****

// Start next delegate in chain

StartUpdateAverageCapitalDelegate();

}

catch (Exception ex)

{

// Exception will be thrown by EndInvoke if Update() threw an exception

Console.Error.WriteLine(ex.ToString());

}

}
 
S

Saperlipopette

Certainly the command you look for :

Server.Transfer(Request.ServerVariables["SCRIPT_NAME"]);
 
S

Steven Cheng[MSFT]

Hi Alan,

From your description, you have a long-time operation at the asp.net page's
serverside code so used a asynthronous call to do the operation and
currently you use the <META http-equiv="refresh" content="5">
tag to refresh the waiting page so that it'll post back to check the async
call's state, but you found it'll make the page
blink so you're wondering how to make the page posted back when he async
call finshed via serverside code, yes?

As for this problem, here are my suggestions:
The <META http-equiv="refresh" content="5">
is used to refresh the page(let it post pack to the serverside), we can
also do this via javascript, such as form.submit();
All this is done at client, because when a page is sent back to client,
there is no relation with serverside, this is also the feature of the
HTTP(stateless ) based application. So we can't make a page at client to
post back via calling a method at serverside.

However, as for the page blinking you mentioned, based on my experience,
most one often use a hidden frame or iframe page to workaround this. We can
make a waiting page, which contain a embeded frame or iframe and the frame
contains the acutal refreshing page, and set the frame's width and height =
1 so as to make it hidden. Then, the hidden page is constantly refreshed,
the main waiting page won't be blinking. How do you think of this?

If you have anything unclear, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
A

Alan Z. Scharf

Steven,

Thanks for your reply.

1. Regarding the use of a hidden frame, would I still be able to display
progress somewhere without blinking?

Right now, every time my main page refreshes, it queries a table in
SQLServer which is being updated with cumulative running time at the end of
each stored procedure in the chain of asynch calls. This table of
cumulative time and other indicators is then displayed in a datagrid on
repost.

2. If not, then can you offer more detail on javascript for resubmitting.

So far, I fould reference to a java command: document.forms[0].submit, but
am not sure how to integrate it into my .aspx page.

Regards,

Alan
 
A

Alan Z. Scharf

Saperlipopette,

I'm still trying to het this to work with my async callbacks.

Regards,

Alan


Saperlipopette said:
Certainly the command you look for :

Server.Transfer(Request.ServerVariables["SCRIPT_NAME"]);



Alan Z. Scharf said:
1. I have a chain of six asynch callbacks initiated by a button, and want
the page to refresh at the end of each callback to display

A. Results of a SQLServer query showing cumulative running time, and
B. A progress bar.

2. I have this working with a refresh timer:

<META http-equiv="refresh" content="5">

3. However, the blinking of page reloads is annoying, and I'd prefer to have
the page reload at exactly the end of each callback EndInvoke.

What is the command to force page reload in C#?

4. One of my HandleCompletions is below, with the place indicated where I
want to reload the page.

Thanks for any help.

Alan

private void HandleUpdateCapitalCompletion(IAsyncResult asyncResult)

{

try

{

// Retrieve Update delegate object

UpdateCapitalDelegate updateCapital = (UpdateCapitalDelegate)
asyncResult.AsyncState;

//Call EndInvoke to get result of UpdateCapital

string updateCapitalResult = updateCapital.EndInvoke(asyncResult);

//*** RELOAD THE PAGE HERE ****

// Start next delegate in chain

StartUpdateAverageCapitalDelegate();

}

catch (Exception ex)

{

// Exception will be thrown by EndInvoke if Update() threw an exception

Console.Error.WriteLine(ex.ToString());

}

}
 
A

Alan Z. Scharf

Steven,

Thanks very much for your reply and the examples. I will try to work
through them tomorrow.

Regards,

Alan
 
A

Alan Z. Scharf

Hi Steve,
secs to serverside and query tables and update values in the page(you can
store them in some <input type="hidden" > fields.<<

Right now I'm refreshing an entire datagrid with status values, not
individual fields.

Will I be able to use the refreshing datagrid on the Refresh page instead of
<input type="hidden" > fields?

I'm still experimenting with what you sent, but wanted to ask this question
in the meantime.

Thanks again..

Alan
 
A

Alan Z. Scharf

Steven,

Thanks again for your reply and example.

I will go through it tomorrow.
the long-run operation has been finished, we display the final result to
the users, do you think so?

I would still like to be refreshing periodically all the way through, rather
than just at the end, since it is a batch process that could take up to
sever minutes, depending on the size of the date ranged covered by the
process.

This web app is duplicating an Access front end to SQLServer that users are
used to. I've been able to duplicate everything, else including
mulltiple-row edits of a datagrid, but this refresh part has been difficult
due to not being connected directly to the database.

When I make a little more progress, I will send you the url of the page
being refreshed.

Thanks again for your help.

Regards,

Alan
 
A

Alan Z. Scharf

Steven,

I was able to get things working by swapping in my components into your
files. They were invaluable!

I have a couple questions remaining, but just now trashed my files somehow -
getting Fatal Engine Execution Error when try to open files in VS.NET.

After I rebuild them I will followup.

Thanks again.

Regards,

Alan
 
A

Alan Z. Scharf

Steven,

1. Just a note to thank you for your help and sample files on the
Refresh/iFrame method of handling async calls.

Everything is working fine.

1. I have one question remaining:

Is there a way to programmatically turn the http-equiv = "refresh" on and
off?

Or some equivalent JScript method?

Thanks.

Alan
 
S

Steven Cheng[MSFT]

Hi Alan,

Thanks for the followup. To answer your question:

1. I have no idea how to control the http-equiv = "refresh" meta of the
page


2. Of course ,we can use javascript code to post a page after a certain
period of time. The
window.setTimeout function is just for such function. For example:
We define the following function "setTimer()" and in it we add the
window.setTimeout("document.forms[0].submit()",1000);
which indicate that the page will be submit 1 second later after we call
this function.

<script language="javascript">

function setTimer()
{
window.setTimeout("document.forms[0].submit()",1000);
}

</script>


Then, we can call this function at the page's clientside's onload event,
just like:
<body onload="setTimer()" >

And if we want to control whether to call it or not at serverside. We can
use
Page.RegisterStartupScript method to programmatically add this script call,
just as below:

private void Page_Load(object sender, System.EventArgs e)
{
Page.RegisterStartupScript("setTimer","<script
language='javascript'>setTimer();</script>");
}

Hope this helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
A

Alan Z. Scharf

Steven,

Thanks again for the detailed example.

I will try it out and let you know how it goes.

Regards,

Alan
 
A

Alan Z. Scharf

Hi Steven,

I realized what I'd like to do is the following:

1. Right now, my Progress page has six async calls and completion handlers.
The Refresh page is continually refreshing every 5 seconds and is contained
in the Progress page as an iFrame..

2. Instead of the continual refreshes of the Refresh page, I would like to
call a refresh (Submit) of the Refresh page as part of each completion
handler on the main Progress page.

That way, the Refresh page would only refresh at completion of each of the
six async routines.

3. Is this possible, i.e. either

(a) calling a "submit" of the iFrame on the Progress page, or

(b) passing a submit command through to the Refresh page from the Progress
page completion handlers?

Thanks again for your help and examples.

Regards,

Alan
 
S

Steven Cheng[MSFT]

Hi Alan,

Thanks for the response. As for the #1 and #2 in your further description,
I don't think they're possible. You means you want to refresh the iframe
page only when the async call finish? Then, I wonder how you make the async
call ,at clientside or at serverside? If at serverside, since the web based
application is request/response mode, we can't get the async call 's call
back and the only way is to constantly refresh the page(post back to
server) to query the serverside state info, do you think so?

As for the
===========================
(a) calling a "submit" of the iFrame on the Progress page, or

(b) passing a submit command through to the Refresh page from the Progress
page completion handlers?
===========================
you mentioned, do you mean using javascript to post back the iframe page ?
If so, this is ok, we can referece the iframe element in the Progress page
via
var frm = document.getElementById(iframeId);

Then call
frm.document.forms[0].submit(); to submit the iframe page(refresh page).

In fact, this is the general javascript skills. Here are some web resources
on manipulating iframe in javascript

http://developer.netscape.com/support/faqs/champions/javascript.html#4
http://www.quirksmode.org/js/iframe.html
http://www.xs4all.nl/~ppk/js/iframe.html

###################

In addition, I'm not sure whether you've ever trying calling webservice via
DHTML javascript in web page? This is also a means to call serverside
webservice in clientside script so as to prevent page be postedback to
server. Here is the reference in MSDN:

#Accessing Web Services From DHTML
http://msdn.microsoft.com/library/en-us/dndude/html/dude01222001.asp?frame=t
rue

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservic
e/overview.asp


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
A

Alan Z. Scharf

Hi Steven,

Thanks again very much for your examples and the references. Your help has
been invaluable!

Regards,

Alan

Steven Cheng said:
Hi Alan,

Thanks for the response. As for the #1 and #2 in your further description,
I don't think they're possible. You means you want to refresh the iframe
page only when the async call finish? Then, I wonder how you make the async
call ,at clientside or at serverside? If at serverside, since the web based
application is request/response mode, we can't get the async call 's call
back and the only way is to constantly refresh the page(post back to
server) to query the serverside state info, do you think so?

As for the
===========================
(a) calling a "submit" of the iFrame on the Progress page, or

(b) passing a submit command through to the Refresh page from the Progress
page completion handlers?
===========================
you mentioned, do you mean using javascript to post back the iframe page ?
If so, this is ok, we can referece the iframe element in the Progress page
via
var frm = document.getElementById(iframeId);

Then call
frm.document.forms[0].submit(); to submit the iframe page(refresh page).

In fact, this is the general javascript skills. Here are some web resources
on manipulating iframe in javascript

http://developer.netscape.com/support/faqs/champions/javascript.html#4
http://www.quirksmode.org/js/iframe.html
http://www.xs4all.nl/~ppk/js/iframe.html

###################

In addition, I'm not sure whether you've ever trying calling webservice via
DHTML javascript in web page? This is also a means to call serverside
webservice in clientside script so as to prevent page be postedback to
server. Here is the reference in MSDN:

#Accessing Web Services From DHTML
http://msdn.microsoft.com/library/en-us/dndude/html/dude01222001.asp?frame=t
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservic
e/overview.asp


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
G

Guest

Hello,

Would it be possible for you to send me these examplea as I can’t see them attached in posts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top