By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Reload Page Command

P: n/a
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());

}

}
Nov 18 '05 #1
Share this Question
Share on Google+
18 Replies


P: n/a
Certainly the command you look for :

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

"Alan Z. Scharf" <as*****@grapevines.com> a écrit dans le message de
news:ea**************@TK2MSFTNGP11.phx.gbl...
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());

}

}

Nov 18 '05 #2

P: n/a
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

Nov 18 '05 #3

P: n/a
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
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:yk*************@cpmsftngxa10.phx.gbl...
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

Nov 18 '05 #4

P: n/a
Saperlipopette,

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

Regards,

Alan
"Saperlipopette" <saperlipopette@null> wrote in message
news:40**********************@news.free.fr...
Certainly the command you look for :

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

"Alan Z. Scharf" <as*****@grapevines.com> a écrit dans le message de
news:ea**************@TK2MSFTNGP11.phx.gbl...
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());

}

}


Nov 18 '05 #5

P: n/a
Steven,

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

Regards,

Alan
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Wo**************@cpmsftngxa10.phx.gbl...
Hi Alan,

Thanks for the followup. Well, I recommend you use the "hidden iframe"
means.
As for your situation, you can make the refresh page(which refresh once 5
secs to serverside and query tables and update values in the page(you can
store them in some <input type="hidden" > fields.

then, embed this refresh page in the waiting page(display progress bar or
something else) via
<iframe id="frmRefresh" width="1" height="1" src="refresh.aspx" >....
And you can use the javascript to retrieve the hidden fields(in the iframe
page)'s value and use it to update your display page.

To make it clearly, I've made two sample pages via C# code I've attached it in the message. You can get it if you view this thread via OE client.
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

Nov 18 '05 #6

P: n/a
Hi Steve,
As for your situation, you can make the refresh page(which refresh once 5
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

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Wo**************@cpmsftngxa10.phx.gbl... Hi Alan,

Thanks for the followup. Well, I recommend you use the "hidden iframe"
means.
As for your situation, you can make the refresh page(which refresh once 5
secs to serverside and query tables and update values in the page(you can
store them in some <input type="hidden" > fields.

then, embed this refresh page in the waiting page(display progress bar or
something else) via
<iframe id="frmRefresh" width="1" height="1" src="refresh.aspx" >....
And you can use the javascript to retrieve the hidden fields(in the iframe
page)'s value and use it to update your display page.

To make it clearly, I've made two sample pages via C# code I've attached it in the message. You can get it if you view this thread via OE client.
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

Nov 18 '05 #7

P: n/a

Steven,

Thanks again for your reply and example.

I will go through it tomorrow.
only at the time 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

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:$E*************@cpmsftngxa10.phx.gbl... Hi Alan,

Thanks for the followup. You mentioned that you'll need to query some
certain tables and retrieve out the datas and stored in a datagrid in the
refreshing page? I'm not sure whether you want to just display the changed
data in a datagrid and show to the users. If so, I think its also ok to put the datas in the datagrid on the refreshing page(in the iframe) and use
javascript to get the datagrid's clientside html and display in the
container page(waiting page) which is actually displayed to the users. I've attached my modified demo pages in this message regarding on this means.

Also, I also think since you use refreshing page and waiting page is just
to wait for a long-run operation to finish. So it's better that we put less displaying logic in refreshing page or waiting page, and only at the time
the long-run operation has been finished, we display the final result to
the users, do you think so?
If you have any updates, 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

Nov 18 '05 #8

P: n/a
Hi Alan,

You're welcome. If you have any new findings or need any further help,
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
Nov 18 '05 #9

P: n/a
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

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:3H**************@cpmsftngxa10.phx.gbl...
Hi Alan,

You're welcome. If you have any new findings or need any further help,
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

Nov 18 '05 #10

P: n/a
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
Nov 18 '05 #11

P: n/a
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


Nov 18 '05 #12

P: n/a


Steven,

Thanks again for the detailed example.

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

Regards,

Alan
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Ve**************@cpmsftngxa10.phx.gbl...
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

Nov 18 '05 #13

P: n/a
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
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Ve**************@cpmsftngxa10.phx.gbl...
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

Nov 18 '05 #14

P: n/a
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/suppor...ascript.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...01.asp?frame=t
rue

http://msdn.microsoft.com/library/de...thor/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



Nov 18 '05 #15

P: n/a
Hi Steven,

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

Regards,

Alan

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:$K**************@cpmsftngxa10.phx.gbl...
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/suppor...ascript.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...01.asp?frame=t rue

http://msdn.microsoft.com/library/de...thor/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


Nov 18 '05 #16

P: n/a
Hello,

Would it be possible for you to send me these examplea as I can’t see them attached in posts?
Nov 18 '05 #17

P: n/a
Hello

I could be going mad here but the link

http://msdn.microsoft.com/newsgroups...bd-57287813491

Shows only text no examples, could you please send me these as I seem to be trying to do exactly what you have done her

:-)
Nov 18 '05 #18

P: n/a
Try using outlookexpress as your newsgroup reader.

It should pick up the attachments.

That may be your problem.

The server address is msnews.microsoft.com

Alan
"David P" <da**********@hotmail.com> wrote in message
news:22**********************************@microsof t.com...
Hello,

I could be going mad here but the link

http://msdn.microsoft.com/newsgroups...d-57287813491d
Shows only text no examples, could you please send me these as I seem to be trying to do exactly what you have done here
:-)

Nov 18 '05 #19

This discussion thread is closed

Replies have been disabled for this discussion.