473,516 Members | 3,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmatically Refreshing the Page

One thing that I have often needed to do that I have been unable to find a
way to do is refresh the page (basically do the same thing as pressing the
browser's Refresh button). I know how to do this using Javascript/JScript,
but I have situations in which I need it to be done immediately after code
that is part of my other code. Is there any way to do this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
10 2160
Hi

Do not know if i am correct did u try meta refresh tag of HTML.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Nov 19 '05 #2
You seem to have misunderstood my question. I want the refreshing to occur
when, and only when, it is called in my code. For example, I might have a
graphic that gets changed when the user presses a button. They do not see
the new graphic unless the page is refreshed. I want to be able to
automatically refresh the page after the graphic is modified, but I don't
want the page to be continually refreshed, because that would be inefficient
and mean that the user might need to wait a certain period of time
(depending on how frequently I set the meta tag to refresh) before seeing
the new graphic.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<sh**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi

Do not know if i am correct did u try meta refresh tag of HTML.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Nov 19 '05 #3
"Nathan Sokalski" <nj********@hotmail.com> wrote in
news:u6**************@TK2MSFTNGP12.phx.gbl:
You seem to have misunderstood my question. I want the refreshing to
occur when, and only when, it is called in my code.


I think you have a misunderstanding of how the web works... The web works
in a request-response fashion, only clients can make requests for data.
Hence, the server (ASP.NET) can force a refresh.

There are a couple solution to emulate what you want:

1. Refresh continously
2. Poll the server via javascript remoting, when the server returns a
positive response, refresh thte apge

Option 1 is easy. Option 2 takes some knowledge of javascript.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #4
Nathan,

I assume that the other sample I did sent in your other questions give you
an answer on this?

I hope this helps,

Cor
Nov 19 '05 #5
Ok got it then you can use Cache object where you can specify when the
object changes referesh the cache.

Cache object can further be customized on lot of parameter like values
, time , change in file etc etc.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Nov 19 '05 #6
Hi, Nathan.

You might want to take a look at:
"Generating Client-Side Script for Postback"

http://msdn.microsoft.com/library/de...orpostback.asp

That article explains how to generate a postback event
in controls other than buttons and image buttons.

Make sure you follow through to the accompanying article:
http://msdn.microsoft.com/library/de...riptsample.asp

That sample creates a custom link button
that initiates postback through client-side script.

For a sample which derives from WebControl,
see "Rendering a Server Control Samples" :

http://msdn.microsoft.com/library/de...olssamples.asp

I see what might be a problem in using these methods, and it's that
synchronizing the client-side script so that it executes *after* your
new image has been created might be tricky.

You might want to consider adding a "Please wait..." message
or a progress bar to your code and introducing a time delay
for the postback to occur, so that enough time elapses before
the page is refreshed by the postback.

For "Please wait..." and progress bar example code, see :

http://www.daveandal.net/books/6744/...implewait.aspx
http://www.daveandal.net/books/6744/...ogressbar.aspx

There's links to source code in both.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
You seem to have misunderstood my question. I want the refreshing to occur when, and
only when, it is called in my code. For example, I might have a graphic that gets
changed when the user presses a button. They do not see the new graphic unless the page
is refreshed. I want to be able to automatically refresh the page after the graphic is
modified, but I don't want the page to be continually refreshed, because that would be
inefficient and mean that the user might need to wait a certain period of time
(depending on how frequently I set the meta tag to refresh) before seeing the new
graphic.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<sh**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi

Do not know if i am correct did u try meta refresh tag of HTML.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/


Nov 19 '05 #7
I'm not sure if this will help but; this is what I do when I want the page
to be refreshed. It is server based, I find it nessary if a resource on the
server has changed and I want it reflected in the browser.

Public Shared Sub RefreshPage()
Dim httpCxt As System.Web.HttpContext = GetHTTPContext()
httpCxt.Response.Redirect(httpCxt.Request.RawUrl) ' RawUrl contains
the full url, including parameters.
End Sub

Public Shared Function GetHTTPContext() As System.Web.HttpContext
Return (System.Web.HttpContext.Current)
End Function
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
One thing that I have often needed to do that I have been unable to find a
way to do is refresh the page (basically do the same thing as pressing the
browser's Refresh button). I know how to do this using Javascript/JScript,
but I have situations in which I need it to be done immediately after code
that is part of my other code. Is there any way to do this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #8
Quick and dirty:

Use SendKeys to send an {f5} to the IE window - bingo
http://msdn.microsoft.com/library/de...ClassTopic.asp

Good luck

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
You seem to have misunderstood my question. I want the refreshing to occur
when, and only when, it is called in my code. For example, I might have a
graphic that gets changed when the user presses a button. They do not see
the new graphic unless the page is refreshed. I want to be able to
automatically refresh the page after the graphic is modified, but I don't
want the page to be continually refreshed, because that would be
inefficient and mean that the user might need to wait a certain period of
time (depending on how frequently I set the meta tag to refresh) before
seeing the new graphic.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<sh**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi

Do not know if i am correct did u try meta refresh tag of HTML.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/


Nov 19 '05 #9

Nathan -

You can write a little routine to force the page to refresh. You ca
then call this procedure whenever you need to:

In the code behind you will need:

'Build dynamic script to force a postback to the page to get th
new info
Private Sub ForcePostBack()
Dim strRedirectBuilder As StringBuilder = New StringBuilder

strRedirectBuilder.Append("<script language='vbscript'>")
strRedirectBuilder.Append("ForceRefresh()")
strRedirectBuilder.Append("</script>")

Page.RegisterStartupScript("Redirect"
strRedirectBuilder.ToString)

End Sub

Then in your script you would need:

public sub ForceRefresh()
dim strPath
strPath = "<pagename>.aspx"
window.navigate(strPath)
end sub

Hope this helps

--
Rosann
-----------------------------------------------------------------------
Rosanne's Profile: http://www.highdots.com/forums/m28
View this thread: http://www.highdots.com/forums/t266597

Nov 19 '05 #10


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
4248
by: A.Translator | last post by:
I have been struggling with a page that is based on a table structure (because that is all I am feeling comfortable with at the moment) styled with css. One of the problems I run in to is Opera (Opera 7 in my case). The weird thing is: viewing the page through Opera's eyes the first time around is OK, but after refreshing, the page gets...
2
1059
by: Nathan Sokalski | last post by:
One thing that I have often needed to do that I have been unable to find a way to do is refresh the page (basically do the same thing as pressing the browser's Refresh button). I know how to do this using Javascript/JScript, but I have situations in which I need it to be done immediately after code that is part of my other code. Is there any...
1
1909
by: Laurent Liegeois | last post by:
Hi, I try to write a Web Custom Control. But I have a little problem for refreshing the properties view of my Web Control in Visual Studio (). When I modify the value of text property of my Control by programing, it changes in the Design view but no in properties viewAnd when in the design view, I lost the focus and I click above my...
5
3472
by: Jensen Bredal | last post by:
Hello, I need to display self refreshing information on a web page written with asp.net. I would image that the info would be displayed either as part of a user control or a web control. How can this be done? The information will come from a database and the displaying should loop throug a table in the database. Many thank in advance JB
25
45696
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in the future, so the front-end application must have a way to keep up with this (instead of manually linking them).
4
5043
by: Dan | last post by:
Hi, i'm not sure to understand the difference between refreshing the pagina by clicking on 'refresh' in the browser and a postback. What i think it is: Suppose a page with a form containing a textbox and a dropdowlist: and a button to start something n code-behind: a refresh doesn't send any value back to the server but with a postback,...
13
7429
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window will open.My problem is the pop-up window and the parent window has same combobox.if i add data through html form in pop-up window(Ex2.jsp) it enters...
0
2048
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a dialog box ended up opening up a new browser window with the aspx page, I read on a forum that I should use the iframe control and since I have...
1
9384
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a dialog box ended up opening up a new browser window with the aspx page, I read on a forum that I should use the iframe control and since I have...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.