Jul 01
<html>
<head>
<script>
function ByPass()
{
var kCode = window.event.keyCode;
       if(kCode == 112)
      {
             alert('F1 Clicked'); // Alter Code As Your Wish
       }
}
</script>
</head>
<body onhelp="return false;" onkeydown="ByPass()">
</body>
</html>
Jul 01
<html>
<head>
<script>
function incr()
{
var len = document.getElementById('txt').value;
document.getElementById('txt').style.width = 75+len.length*4+'px';
}
</script>
<body>
<input type='text' id='txt' onkeydown='incr()' style='width:75px' />
</body>
</html>
Jul 01
<html>
<body>
<script language="JavaScript">

document.onmousemove = getCoordinate;
var mosX = 0 ;
var mosY = 0 ;
function getCoordinate(e)
{
mosX = event.clientX + document.body.scrollLeft ;

//clientX Property Sets or retrieves the x-coordinate of the mouse
//pointer's position relative to the client area of the window,
//excluding window decorations and scroll bars
//scrollLeft Property Sets or retrieves the distance between the
//left edge of the object and the leftmost portion of the content
//currently visible in the window.

mosY = event.clientY + document.body.scrollTop;

//clientY Property Sets or retrieves the y-coordinate of the mouse
//pointer's position relative to the client area of the window,
//excluding window decorations and scroll bars.
//scrollTop Property Sets or retrieves the distance between the top
//of the object and the topmost portion of the content currently
//visible in the window.

document.title = "(X Co-Ordinate » "+ mosX +") ( "+"Y Co-ordinate » " +mosY+")";
document.getElementById('dx').innerHTML =
"Mouse X ==» "+mosX+"<br>"+"Mouse Y ==» "+mosY;

return true
}

</script>
<div id="dX"></div>
</body>
</html>
Jul 01
Script
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Find KeyCode</title>
<script language="JavaScript">
function TriggeredKey(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
alert("keycode: " + keycode);
}
</script>
</head>
<body onkeydown="TriggeredKey(this)">
</body>
</html>
Special Keyboard Key(s) Code

KeyCode
Backspace      8
Tab            9
Enter         13 
Shift         16 
Ctrl          17 
Alt           18 
Pause/Break   19 
Caps Lock     20 
Esc           27 
Page Up       33 
Page Down     34 
End           35 
Home          36 
Left Arrow    37 
Print Screen  44
Delete        46
F1            112
F2            113
F3            114
F4            115
F5            116
F6            117
F7            118
F8            119
F9            120
F10           121
F11           122
F12           123
Jul 01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

>
<html>
<head>
    <title>Custom Alert Box</title>
    <meta http-equiv="Content-Type" content="text/html;

charset=utf-8">

    <script type="text/javascript" language="javascript">
document.onclick=disableEvents
document.oncontextmenu=disableEvents
var ef=0
function custAlert()
{
ef=1
var ids
ids=document.getElementById('alert')
ids.style.left=300;
ids.style.top=150;
ids.style.visibility="visible"
}

function disableEvents()
{
if(ef)
return false;
}
    </script>

</head>
<body bgcolor="#ffffff" onload="custAlert();">
    <form id="Form1" method="post" runat="server">
        <div align="center" id="alert" style="border: 2px solid gray; background: #cdeb8b
url('images/img3.gif') repeat-x; left: 240; visibility: hidden; width: 349; color: red; position: absolute;
            top: 104; height: 108">
            <br>
            <h3 style="left: 0; width: 152; position: absolute; top: 0; height: 40; ali

gn: Left">
                <font color="#356AA0">Custom Alert Box</font></h3>
            <img style="left: 336px; width: 6px; position: absolute; top: 8px; height: 6px" height="6"
                alt="Close" src="images/Cross.png" onclick="ef=0;document.getElementById('alert').style.visibili

ty='hidden';">
            <br>
            <hr width="99.03%" size="1" style="left: 0px; width: 99.03%; position: absolute;
                top: 32px; height: 1px">
            <div id="msg" style="width: 349; color: #356aa0; height: 85; text-decoration: none">
                NJoy Programming<p>
                    Success be Yours</div>
            <p>
        </div>
    </form>
</body>
</html>
Jul 01
A very common requirement that comes up when building a form with lot of fields is resetting the controls back to their original state. In this article, we will explore how to do this task using both ASP.NET and Javascript. I assume you know how to build web pages in asp.net 2.0.
Using ASP.NET
Step 1: Drag and drop a few controls like textboxes, radio buttons, checkboxes etc. on to the form
Step 2: Add a button to the form and rename its Text property as “Clear all controls using ASP.NET”. Rename its id property to be “btnClearASP”.
Step 3: Double click the button. In its click event, call a method that will clear the content of the controls on a Page.
protected void btnClearASP_Click(object sender, EventArgs e)
{
ResetFormControlValues(this);
}
Step 4: Write code for this method
private void ResetFormControlValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.Controls.Count > 0)
{
ResetFormControlValues(c);
}
else
{
switch(c.GetType().ToString())
{
case “System.Web.UI.WebControls.TextBox”:
((TextBox)c).Text = “”;
break;
case “System.Web.UI.WebControls.CheckBox”:
((CheckBox)c).Checked = false;
break;
case “System.Web.UI.WebControls.RadioButton”:
((RadioButton)c).Checked = false;
break;
}
}
}
}
The above function is a recursive function that clears the controls values on a page. I am not sure if this will work for a collection control like a RadioButtonList or similar. But I hope you have got some idea of how to write a function to reset contents on a page.
Using Javascript
Step 1: Drag and drop a few controls like textboxes, radio button, checkboxes etc. on to the form.
Step 2: Drag and drop a html button on the form. Rename it to “Clear All Controls Using Javascript”. Add an ‘OnClick’ attribute and point it to a function “ClearAllControls()” as shown below
<input id=”Button1″ type=’button’ onclick=’ClearAllControls()’ value=’Clear All Controls Using Javascript’/>

Step 3: Write code for this function ‘ClearAllControls()’.