Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can we detect browser refresh in asp.net

Posted on 2004-10-15
7
Medium Priority
?
423 Views
Last Modified: 2012-08-14
I am creating one project in ASP.Net using VB.Net. Is there any event that I can detect that Browser is REFRESHED. Kindly provide me the code with example. Also give code if user click BACK button of Browser and close Browser.
0
Comment
Question by:nabilpk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 12319886
try Page_Load procedure:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   ''your code here
End Sub
0
 
LVL 1

Expert Comment

by:srini5474
ID: 12355907
yes it is possiable to find weather the page is refreshed in asp.net as specified by YZlat
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

'in this function u can use

If Not Page.IsPostBack Then
          ' Checks weather page is loaded first time if yes it continues code witin this block
Else
        ' if page is refreshed it come to else part and u can execute the code   needed for refresh
Endif

End Sub

or u can do it like


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

//inside this function u can use

If Page.IsPostBack Then
         // Checks weather page is refreshed or reloaded again if yes it execute the code in this part
Else
        //if page is loaded first time it execute the code in this block      
Endif
End sub

this works fine check it out

Regards,
Srini
0
 
LVL 1

Expert Comment

by:srini5474
ID: 12356176
This code help u to detect  close browser
<html>
<head>
<Script>
function onClose(){
if(window.screenTop>10000){
alert("Good Bye , visit us soon !")
}
}
window.onunload=onClose

</Script>
</head>

<body>    
Try to close the window and see the alert msg
</body>
</html>

it works fine
Regards,
Srini
0
 
LVL 1

Accepted Solution

by:
srini5474 earned 500 total points
ID: 12356194
This link would help u to use Back button effectively in IE
http://www.javascript-2.com/back-button.html
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question