Wednesday, 27 February 2013

Disable mouse right click using javascript


When we right click on the page and click on the view source option then page html source along with inline css will see. From the source code, they can figure out how you did things and where your graphics are stored, or just plain old copy your content coding. To prevent the user to know the source detail we disable right click on the page.

<script type="text/javascript">
        var message = "Right Click Disabled!";
        function DisableIE() {
            if (event.button == 2) { alert(message); return false; }
        }
        function DisableOther(e) {
            if (document.layers || document.getElementById && !document.all)
            { if (e.which == 2 || e.which == 3) { alert(message); return false; } }
        }
        if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = DisableOther; }
        else if (document.all && !document.getElementById) { document.onmousedown = DisableIE; }
        document.oncontextmenu = new Function("alert(message);return false")
</script>

Disable F12 key in the browser


When user press F12 key, browsers developer tool bar will open in the below portion of the browser. By
using the developer tool bar user can see the design, javascript code and corresponding css applied to the controls in the page. To prevent the user to do that we will the hide developer tool bar.

You can use the below code to do that. Write the below code in the head section of the page.
<script type="text/javascript">

document.onkeydown = function (event)
{
     event = (event || window.event);
     if (event.keyCode == 123 || event.keyCode == 18)
     {
           alert("This function is disabled here");
           return false;
     }
}
</script>

Monday, 25 February 2013

Request format is unrecognized for URL unexpectedly ending in


Add the following to web.config since GET and POST are disabled by default in ASP.NET 2.0 and greater:

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

Build the project and run.

Sunday, 24 February 2013

Show Logo on Title Bar

1 - Take a small logo image of 16*16 pixel.
2 - Put that image in the image folder of the project.
3 - In the master page write the below line.
      <link type="image/x-icon" rel="Logo" href="Image/sanjeet.ico" />
      Here my icon name is sanjeet.ico.
4 - Press F5 to run your project.