473,322 Members | 1,911 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,322 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 4602
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.