Solved

Can we detect browser refresh in asp.net

Posted on 2004-10-15
7
405 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This link would help u to use Back button effectively in IE
http://www.javascript-2.com/back-button.html
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

762 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

11 Experts available now in Live!

Get 1:1 Help Now