Sunday, December 21, 2008

pdf search engine - find pdf

www.pdf-search-engine.com/

A great site to search pdf files

Saturday, September 29, 2007

Return random rows using Sql query

Return random rows using Sql query

SELECT TOP 5 * FROM album ORDER BY NEWID()

Reloading A Page in javascript

Reloading A Page in javascript

location.reload();
reloading by preventing caching:location.search = "?" + Math.random();

Redirecting a browser using javascript

Redirecting a browser using javascript


location.href = "newPage.html";

OR

<meta http-equiv="Refresh" content="X; URL=Y" />


OR

location.replace("newPage.html"); (This refreshes browser history)

prevent caching in javascript

prevent caching in javascript


document.write("<img src=\"yourimage.gif?" + Math.random() + "\" />");

Here Math.random() is the key here since its always different per load and enforces a different version!!.

Math.random() returns a random number between 0 and 1 (Eg:0.something..)

Get Browser Type using Javascript

Get Browser Type using Javascript

<script language="JavaScript"
type="text/javascript">

function getBrowserType() {
var bo = navigator.userAgent;
var browserType = "unknown";
if (bo.indexOf("Opera") > -1) {
browserType = "Opera";
} else if (bo.indexOf("Safari") > -1) {
browserType = "Safari";
} else if (bo.indexOf("Konqueror") > -1) {
browserType = "Konqueror";
} else if (bo.indexOf("Gecko") > -1) {
browserType = "Mozilla";
} else if (bo.indexOf("MSIE") > -1) {
browserType = "Internet Explorer";
}
//window.alert(browserType);
return browserType;
}
</script>


To get version no you may use the following (but have to exact version no):
window.alert(navigator.userAgent);


Result might look like:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en;
rv:1.8.0.3) Gecko/20060426 Firefox 1.5.0.3
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.4) Gecko/20030619 Netscape/7.1 (ax)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
.NET CLR 2.0.50727)
Mozilla/5.0 (compatible; Konqueror/3.4; FreeBSD)
KHTML/3.4.2 (like Gecko)
Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en)
AppleWebKit/418 (KHTML, like Gecko)
Safari/417.9.3
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
AppleWebKit/312.8 (KHTML, like Gecko)
Safari/312.6
Opera/9.00 (Windows NT 5.1; U; en)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
en) Opera 9.00



Currently the following type of browser are available:

Internet Explorer
Mozilla Browsers
Konqueror (KDE)
Apple Safari
Opera Browser

Cache dataset in asp.net

Cache dataset in asp.net
===================


use the namespace : System.Web.Caching.Cache

Add dataset to cache :
Cache.Insert("yourDataSet",ds,null,DateTime.Now.AddSeconds(15),System.TimeSpan.Zero);

Remove dataset from cache:
Cache.Remove("yourDataSet");

load dataset from cache:

if(Cache["CustomersDataSet"] != null) {
ds = (DataSet)Cache["yourDataSet"];
}
else {
//logic to insert dataset to cache (i.e. load dataset and put it into cache)
}