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
Solved

Can we detect browser refresh in asp.net

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
This video teaches users how to migrate an existing Wordpress website to a new domain.

860 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