Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Saturday, September 24, 2011

How To Stopping Your User From Right -Clicking


Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It’s not foolproof, but this neat little HTML edit usually does the trick.
Just alter the opening <body> tag of your HTML to the following:


<body oncontextmenu="return false">

When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

Thursday, February 3, 2011

How To Stopping Your User From Right -Clicking


Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It’s not foolproof, but this neat little HTML edit usually does the trick.
Just alter the opening <body> tag of your HTML to the following:


<body oncontextmenu="return false">

When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

Wednesday, February 2, 2011

How to Raise Events for FILEUPLOAD Control


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

<!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 runat="server">

   <script type="text/javascript">
function GetFileName(val)
{
   var i = val.lastIndexOf("\\");
   return val.substring(i+1);
}
   </script>

   <title>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
       <div>
           <asp:FileUpload ID="FileUpload1" runat="server" size="40"
onchange="this.form.TextBox1.value=GetFileName(this.value);" />
           <asp:TextBox ID="TextBox1" runat="server" />
       </div>
   </form>
</body>
</html>

Restrict Alphabet Input In TextBox


<html>
<head>

    <script language="javascript">
        function blockChar(e) {
            var keyVal = (window.event) ? event.keyCode : e.keyCode;
            if (window.event) keyVal = window.event.keyCode;
            if ((keyVal > 64 && keyVal < 93)) {
                return false;
            }
        }
    </script>

</head>
<body onload="javascript:document.getElementById('txt').focus();">
    <input type="text" id='txt' onkeydown="return blockChar(this);" />
</body>
</html>