Solved

Can we detect browser refresh in asp.net

Posted on 2004-10-15
7
408 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
  • 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 125 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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.

930 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now