473,469 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Should this code force a refresh of my asp.net page?

I have a button in my asp.net page (actually its in a user control
with a .ASCX suffix) called btnGetData. I'm trying to make it force a
refresh of my page. So what I did was make it call javascript.
Should the following work? (It doesn't seem to)

Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
LoadGridView()
ForcePageRefresh()
End Sub
Sub ForcePageRefresh()
Dim popupScript As String
Dim instance As ClientScriptManager

instance = Page.ClientScript
popupScript = "<script language='JavaScript'>"
popupScript = popupScript & "
window.location.reload( true );"
popupScript = popupScript & "</script>"
instance.RegisterStartupScript(GetType(String), "PopupScript",
popupScript)
End Sub
Jun 27 '08 #1
3 2098
have no idea why on a postback, your code would render a command to request
the same page again to get the html, instead of returning the correct html
(sloppy coding I guess). you can just use Response.Redirect, no need for
javascript.

for either approach to work you shoudl decorate the url (add a dummay
parameter) to force a fresh copy rather than using a cached copy.

-- bruce (sqlwork.com)
"CO*********@lycos.com" wrote:
I have a button in my asp.net page (actually its in a user control
with a .ASCX suffix) called btnGetData. I'm trying to make it force a
refresh of my page. So what I did was make it call javascript.
Should the following work? (It doesn't seem to)

Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
LoadGridView()
ForcePageRefresh()
End Sub
Sub ForcePageRefresh()
Dim popupScript As String
Dim instance As ClientScriptManager

instance = Page.ClientScript
popupScript = "<script language='JavaScript'>"
popupScript = popupScript & "
window.location.reload( true );"
popupScript = popupScript & "</script>"
instance.RegisterStartupScript(GetType(String), "PopupScript",
popupScript)
End Sub
Jun 27 '08 #2
On 2 May, 15:38, COHENMAR...@lycos.com wrote:
I have a button in my asp.net page (actually its in a user control
with a .ASCX suffix) called btnGetData. *I'm trying to make it force a
refresh of my page. *So what I did was make it call javascript.
Should the following work? *(It doesn't seem to)

* Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
* * * * LoadGridView()
* * * * ForcePageRefresh()
* * End Sub

* * Sub ForcePageRefresh()
* * * * Dim popupScript As String
* * * * Dim instance As ClientScriptManager

* * * * instance = Page.ClientScript
* * * * popupScript = "<script language='JavaScript'>"
* * * * popupScript = popupScript & "
window.location.reload( true );"
* * * * popupScript = popupScript & "</script>"
* * * * instance.RegisterStartupScript(GetType(String), "PopupScript",
popupScript)
* * End Sub
Hi

I am intrigued as to why you want to do this. Could it be that you are
trying to trigger execution of code on the host page when a User
Control button is clicked?
Jun 27 '08 #3
Can you give the reason why u want to reload the same (loading) page again n
again ?

<CO*********@lycos.comwrote in message
news:8e**********************************@y21g2000 hsf.googlegroups.com...
>I have a button in my asp.net page (actually its in a user control
with a .ASCX suffix) called btnGetData. I'm trying to make it force a
refresh of my page. So what I did was make it call javascript.
Should the following work? (It doesn't seem to)

Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
LoadGridView()
ForcePageRefresh()
End Sub
Sub ForcePageRefresh()
Dim popupScript As String
Dim instance As ClientScriptManager

instance = Page.ClientScript
popupScript = "<script language='JavaScript'>"
popupScript = popupScript & "
window.location.reload( true );"
popupScript = popupScript & "</script>"
instance.RegisterStartupScript(GetType(String), "PopupScript",
popupScript)
End Sub

Jun 27 '08 #4

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

Similar topics

1
by: Charles Soto | last post by:
I've got a main loop script that calls two other scripts that do no user interaction. All they do is send a couple of mysql update statements. Then they use header() to call the main loop again. ...
1
by: Piyush Parmar | last post by:
Hi. I would like to know if it's possible to force a dialog box to "expire" after so many seconds? The scenario is that I'm holding various objects in my session. Before it times out, I want...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
4
by: Alex | last post by:
Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params....
10
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application and I need to find a way to cause a page refresh from within my application. Does anyone know how to force the browser to refresh the current page? ...
4
by: Paul Drummond | last post by:
Is there a way to force a page refresh, so users will not receive a cached version of a page, even if they have their browser set to never check for a newer version of page? Thank you!
0
by: philaphan80 | last post by:
Is there a way to force the Visual Studio IDE (Page Control at design- time) to refresh / repaint itself upon drag & drop of *any* item from the toolbox? Perhaps a method I need to override within...
0
by: Summercool | last post by:
right now i have a script that will add to the DOM tree of a form... adding the hidden input values as children... it works well except when i click "BACK", Firefox doesn't remove those objects......
2
by: Hrvoje Vrbanc | last post by:
Hello! I have an ASP.NET page that displays some data from an SQL Server 2005 database, using a Select query. The database is updated by another piece of software, independently of the ASP.NET...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.