Thursday, October 16, 2014

How To Disable Right Click Using jQuery

There are many different ways where we can disable right click on browser but using jQuery its very easy with one line of code.

Add the below code into the head section of your web page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(document).bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script>

How To Show A Message When DataList Is Empty

DataList doesn’t have EmptyDataTemplate like GridView or ListView, Here is how we can achieve use FooterTemplate in DataList

<FooterTemplate>
<asp:Label ID="lblEmpty" Text="No test types found." runat="server"
Visible='<%#bool.Parse((SearchValuesList.Items.Count == 0).ToString())%>'> </asp:Label>
</FooterTemplate>


Sunday, September 21, 2014

How To Encrypt Stored Procedure In SQL Server

There are some situations where business logics wants to hide the logic implementation, in those scenarios schema of the stored procedure can be encrypted.

Use AdventureWorks2008
go

CREATE PROCEDURE uspEncryptedPersonAddress
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON
SELECT * FROM Person.Address
END


If some one try to view using sp_helptext this is what they see


The text for object 'uspEncryptedPersonAddress' is encrypted.

Thursday, September 11, 2014

How To Display Current Time on Page using Javascript

Here is the JavaScript function which will get current time in Military format.

<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('Showtime').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}

function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>

Sunday, August 24, 2014

How To Copy Content From a protected Webpage

Sometimes it is very annoying when you want to copy any news or article or anything that you want to save and when you right clicks on it but it shows “Right click disabled”. Here are some tips that can be useful on different browsers

For Mozilla FireFox:

Step 1: Open any website that have blocked your right click.
Step 2: Go to Tools>Options>Content
Step 3: Uncheck the box “Enable JavaScript”
Step 4: Click OK

For Internet Explorer:

Step 1: Open the site.
Step 2: Go to Tools>Internet options>Security
Step 3: Now Click on Custom Level
Step 4: Now find Scripting Section it will be around the end.
Step 5: Now disable Active Scripting.This will disable JavaScript and vbscript in your browser.
Step 6:Click on OK.

For Google Chrome:

Step 1: Open the site.
Step 2: Go to settings.
Step 3: Expand Show Advance settings, On Privacy tab.Click on Content Settings.
Step 4: Disable java script and open the website.