473,804 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ 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_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnGetData.Clic k
LoadGridView()
ForcePageRefres h()
End Sub
Sub ForcePageRefres h()
Dim popupScript As String
Dim instance As ClientScriptMan ager

instance = Page.ClientScri pt
popupScript = "<script language='JavaS cript'>"
popupScript = popupScript & "
window.location .reload( true );"
popupScript = popupScript & "</script>"
instance.Regist erStartupScript (GetType(String ), "PopupScrip t",
popupScript)
End Sub
Jun 27 '08 #1
3 2117
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.Redire ct, 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*********@ly cos.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_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnGetData.Clic k
LoadGridView()
ForcePageRefres h()
End Sub
Sub ForcePageRefres h()
Dim popupScript As String
Dim instance As ClientScriptMan ager

instance = Page.ClientScri pt
popupScript = "<script language='JavaS cript'>"
popupScript = popupScript & "
window.location .reload( true );"
popupScript = popupScript & "</script>"
instance.Regist erStartupScript (GetType(String ), "PopupScrip t",
popupScript)
End Sub
Jun 27 '08 #2
On 2 May, 15:38, COHENMAR...@lyc os.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_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnGetData.Clic k
* * * * LoadGridView()
* * * * ForcePageRefres h()
* * End Sub

* * Sub ForcePageRefres h()
* * * * Dim popupScript As String
* * * * Dim instance As ClientScriptMan ager

* * * * instance = Page.ClientScri pt
* * * * popupScript = "<script language='JavaS cript'>"
* * * * popupScript = popupScript & "
window.location .reload( true );"
* * * * popupScript = popupScript & "</script>"
* * * * instance.Regist erStartupScript (GetType(String ), "PopupScrip t",
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*********@ly cos.comwrote in message
news:8e******** *************** ***********@y21 g2000hsf.google groups.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_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnGetData.Clic k
LoadGridView()
ForcePageRefres h()
End Sub
Sub ForcePageRefres h()
Dim popupScript As String
Dim instance As ClientScriptMan ager

instance = Page.ClientScri pt
popupScript = "<script language='JavaS cript'>"
popupScript = popupScript & "
window.location .reload( true );"
popupScript = popupScript & "</script>"
instance.Regist erStartupScript (GetType(String ), "PopupScrip t",
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
2297
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. This works fine, EXCEPT the mysql statement isn't finished by the time the main loop is called. This is a problem because the main loop actually queries that same table to show the value of the rows you just changed. If I refresh the page...
1
2634
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 to notify the user to click Okay to save the work now OR click cancel to refresh the page. What if the user doesn't respond to the dialog box for a long time and then hits save? Well the session has already timed out! So, can I have the dialog...
1
10861
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
6000
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. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred. I have tried using Request.Params.Remove("HiddenField"),...
10
23421
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? Thanks very much for your help! Fred
4
2548
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
2279
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 the page control? I'm aware of using "ComponentModel.RefreshProperties(RefreshProperties.All)" within custom controls, but that only refreshes the page when something specific to that custom control is changed. I'm looking for a way to hook...
0
3956
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... (IE 7 and Safari 3 both removed them). So Firefox will actually submit more objects that there really are. so Firefox (2.0.0.8) is the only one causing trouble... is there a way to "force" refresh of the page or reload it? if i refresh...
2
2202
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 page. The ASP.NET page only displays data and it has nothing to do with inserting or updating data. What is the best way to force the refresh of the ASP.NET page every time a new record is inserted in the table?
0
9593
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10335
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.