474,044 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deactivate Refresh and F5 event

5 New Member
hi

Any one can help me.

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

Please
Sep 19 '07 #1
3 4635
aliasruel
73 New Member
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="javas cript">
function disableKey(even t) {
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.setTimeo ut("window.stat us='';", 2000);

// Standard DOM (Mozilla):
if (event.preventD efault) event.preventDe fault();

//IE (exclude Opera with !event.preventD efault):
if (document.all && window.event && !event.preventD efault) {
event.cancelBub ble = true;
event.returnVal ue = false;
event.keyCode = 0;
}
return false;
}
}

function setEventListene r(eventListener ) {
if (document.addEv entListener) document.addEve ntListener('key press', eventListener, true);
else if (document.attac hEvent) document.attach Event('onkeydow n', eventListener);
else document.onkeyd own = eventListener;

if (!document.getE lementById) return;
var el = document.getEle mentById("Msg") ;
if (el) el.innerHTML = "Event handler added.";
}

function unsetEventListe ner(eventListen er) {
if (document.remov eEventListener) document.remove EventListener(' keypress', eventListener, true);
else if (document.detac hEvent) document.detach Event('onkeydow n', eventListener);
else document.onkeyd own = null;

if (!document.getE lementById) return;
var el = document.getEle mentById("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
subbusuresh
5 New Member
hi,

its very useful to me

Thank You...
Sep 19 '07 #3
Plater
7,872 Recognized Expert Expert
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
3798
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 save their changes and they can respond with yes, no or cancel. If they press cancel, the entry form stays active with the changes still entered. So, if I'm on the entry form and have entered data, and then click on the menu, the deactivate event...
9
7944
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 remember that I clicked a button before the refresh. Here is what is going on: 1) Page Loads 2) User enters some values, clicks the "Save" button 3) The onClick event handler for the save button saves the data to the database and the page is...
0
1113
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 that you can choose from to catch the event a windows form looses focus. What I'm trying to accomplish is when the browser or the page looses focus or is inactive (via minimize) or user switch to another application, I would erase the current...
3
3536
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 that I avoided it. I now have a project with MDI child forms and non-MDI child forms coming and going as the user selects different options. I need to know which form is the active one and thought that I could use the Activate and Deactivate...
1
2902
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. :confused:
1
1516
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 subfolder. Any ideas? Thanks, Keith
12
6064
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
3542
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. But when we click on "Refresh" button on the browser, the query is fired again and again one vote is added un-necessarily..Only one vote should be posted from each pc / user. Same thing is with "Back" button on browser. when we click on vote,...
0
1516
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 process and I have not changed the default object pool settings. Please advise. Event Type: Error Event Source: COM+ Event Category: Unknown Event ID: 4786 Date: 11/2/2006
0
10546
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12140
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8698
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7868
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6652
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.