473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Deactivate Refresh and F5 event

hi

Any one can help me.

how to deactivate the Refresh / F5 Event in asp.net

Please
Sep 19 '07 #1
3 4605
Hi,

Open the inline code of your webform and then you may paste this code below. this code will prevent the F5/Refresh event.
================================================== ===
<script language="javascript">
function disableKey(event) {
if (!event) event = window.event;
if (!event) return;
var keyCode = event.keyCode ? event.keyCode : event.charCode;
//window.status = keyCode;
//alert(keyCode);

// keyCode for F% on Opera is 57349 ?!

if (keyCode == 116) {
window.status = "F5 key detected! Attempting to disabling default response.";
window.setTimeout("window.status='';", 2000);

// Standard DOM (Mozilla):
if (event.preventDefault) event.preventDefault();

//IE (exclude Opera with !event.preventDefault):
if (document.all && window.event && !event.preventDefault) {
event.cancelBubble = true;
event.returnValue = false;
event.keyCode = 0;
}
return false;
}
}

function setEventListener(eventListener) {
if (document.addEventListener) document.addEventListener('keypress', eventListener, true);
else if (document.attachEvent) document.attachEvent('onkeydown', eventListener);
else document.onkeydown = eventListener;

if (!document.getElementById) return;
var el = document.getElementById("Msg");
if (el) el.innerHTML = "Event handler added.";
}

function unsetEventListener(eventListener) {
if (document.removeEventListener) document.removeEventListener('keypress', eventListener, true);
else if (document.detachEvent) document.detachEvent('onkeydown', eventListener);
else document.onkeydown = null;

if (!document.getElementById) return;
var el = document.getElementById("Msg");
if (el) el.innerHTML = "Event handler removed.";
}
</script>


fortunately it l works with Netscape 7.1 and IE6 and Mozilla 1.6
:)

Best Regards,
Ruel Sucgang



================================================== ====
hi

Any one can help me.

how to deactivate the Refresh / F5 Event in asp.net

Please
Sep 19 '07 #2
hi,

its very useful to me

Thank You...
Sep 19 '07 #3
Plater
7,872 Expert 4TB
You should be using the isPostback boolean to deterimine if someone has clicked a button or pushed refresh
Sep 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Maxine G | last post by:
I have two forms, a menu and a data entry form. The entry form is bound to a query against linked SQL server tables. In the deactivate event, I have some code which asks the user if they want to...
9
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't...
0
by: henrycortezwu | last post by:
Hi, I would like to inquire on how to make an event that will simulate the browser loosing focus, or the browser deactivate or inactive state event. Like in Windows Form, there are several events...
3
by: active | last post by:
I remember when I checked NewGroups for comments about the VB6 Activate event and found that many thought it was not a reliable way to keep track of which form has focus. There was enough bad press...
1
by: mailmeramya13 | last post by:
hey , i want to deactivate the f5 button and refresh button and also the close button of the browser. how to work with it. how touse the keycode for this. any body plzzzzzzzzzzzz help. ...
1
by: keithb | last post by:
A CreateUserWizard with one intermediate step (select role) works OK in the root folder, but fails to fire the Deactivate event handler for the intermediate step when the web page is moved to a...
12
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
by: sagarp86 | last post by:
How to lock / deactivate "Refresh" and "Back" button on browser. Problem is in voting application. Once we click for a vote application goes to next page and increament one vote in the database....
0
by: Arif Khan | last post by:
I am getting folllowing error in one of the service components. I have not override base class's (ServicedComponent ) Deactivate function. Also it's library component called by asp.net worker...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.