Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Posts Tagged ‘Browser’

Detect browser F5 / refresh and X / Close in javascript

Posted by Viral Sarvaiya on May 8, 2012

Below javascript is use to detect wether browser is refereshed or closed.

window.onunload = function (e) {
// Firefox || IE
e = e || window.event;
var y = e.pageY || e.clientY;

if (y < 0) {
else {



Posted in ASP.NET, Javascript, Silverlight | Tagged: , , , , , | 2 Comments »

Prevent Silverlight XAP file from caching in your browser.

Posted by Viral Sarvaiya on January 19, 2012

Sometime when we deploy silverlight project, that happen often that when you run website it run older deploy project. because that comes from the cache,

so clear the cache of the Browser and some time that problem occur also after clearing cache.

so for that we have to force website to download new version of xap file every time when it run.

normally we have tag for XAP file, as like below

<param name="source" value="/ClientBin/SilverApp.xap" />

but we have to download our XAP file new at every run of site.

so there so many option for that.

1) changing the Assembly and File version numbers

2) GUID value for the project

but, here is the simple and best solution for that and then it worked like a charm everytime.

<param name="source" value="/ClientBin/SilverApp.xap?ignoreme=<%=System.DateTime.Now.ToUniversalTime()%>" />


Posted in .Net, ASP.NET, Silverlight | Tagged: , , , , , , , , , | 1 Comment »

%d bloggers like this: