How to disable F5 keyword using Javascript in asp.net ?


We can disable F5 Keyword using Javascript like this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CloseBrowserTest.aspx.cs" Inherits="CloseBrowserTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">;
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
document.attachEvent("onkeydown", my_onkeydown_handler)
function my_onkeydown_handler()
{
if(event.keyCode == 116)
{
event.keyCode = 0;
event.returnValue = false;
}
}
</script>

</head>
<body onload="return my_onkeydown_handler()">
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

Advertisements

3 Responses to “How to disable F5 keyword using Javascript in asp.net ?”

  1. How to disable the F5 key - jQuery Solution - Developers Q & A Says:

    […] Also have a look at below link:   https://chandradev819.wordpress.com/2010/07/03/how-disable-f5-keyword-using-javascript-in-asp-net/%5B^] answerCall this function on the onKeyDown […]

  2. simran Says:

    nice code

  3. rosauragrasser Says:

    I like the helpful info you provide in your articles.
    I’ll bookmark your weblog and check again here regularly.
    I’m quite certain I will learn lots of new stuff right here!
    Best of luck for the next!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: