Sometimes we don't want to show our page source code to the end-user.
Anyone can see our page source code by clicking
1.F12
2. Right-click ->View Page Source/ Inspect
3. Ctrl+Shift+I
4. Ctrl +Shift+J
5. Ctrl+U
So to handle this situation we can write a script code on our .net page. Here we have restricted Right Click,F12 key, Ctrl+Shift+I, Ctrl+Shift+J, and Ctrl+U.
Before moving ahead, we have to collect some knowledge about the keyboard keycodes
Step1
Add a web form.
Inside the <head> tag write the following code
<%--CDN--%>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
window.oncontextmenu = function () {
return false;
}
$(document).keydown(function (event) {
if (event.keyCode == 123) {
return false;
}
else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74) || (event.ctrlKey && event.keyCode == 85)) {
return false;
}
});
</script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
alert("Hello! Welcome to My Palm Book")
});
});
</script>
Step2
Inside <body> tag write these code
<form id="form1" runat="server">
<div>
Powered by <a href="https://www.mypalmbook.com/" style="color:orange" target="_blank">My Palm Book</a>
<br/>
<br/>
<input type="text" style="width:20%" class="form-control" />
<button>Submit</button>
<p></p>
</div>
</form>