Solved

Can we detect browser refresh in asp.net

Posted on 2004-10-15
7
409 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

776 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