473,414 Members | 1,636 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,414 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 4607
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.