Windows 8 store apps

I love these store apps. The most interesting and promising feature is integration of html, css technologies as well as support for .Net languages like C# etc.

Windows 8 store apps are nothing but those acquired from Windows store and are different from desktop applications. All the store apps runs in a restricted app container.

Html/Jscript based apps mainly aimed at jscript/html developers. These apps uses WinJS toolkit and WinRT(windows run time). WinJS toolkit provides JS classes, helpers, patterns, html implementation of controls etc where as WinRT javascript api provides api to access platform features.

Windows 8 provides WinRT api to access platform core features like networking, storage, media, graphics etc. This api can be accessed from Javascript, C#, C++ and VB.




I’m a web developer and is flexible with html/jscript, xaml/c# apps. I choose xaml/c# if advanced functionality and behaviour are required in my app. Html/jscript apps are simple and quick to develop(you just need a html and jscript files).


Ajax File Download

How to download a file with events as like that of Ajax Upload. Its impossible to attach an event before and after a download through javascript. Browser doesn’t allow this type of events for security reasons. Usually a file can be downloaded simply clicking on <A> link pointing to the URL and browser prompts a save dialog to the user.

A file download sometimes may take several minutes, there is no way to display a progress message (ex: downloading.. please wait) to the user like that of Ajax loading (once save dialog displayed , it should be hidden).

I have developed a Javascript plugin and server side code in C#(any language it will work as long as same pattern used) to make this possible. This plugin is entirely developed using MS Ajax code and it well works with other libraries(JQuery etc..). I have used IFrame along with cookies for this.

You’ll require MS Ajax library(MicrosoftAjax.js, go for .Net 3.5 to work with JQuery) to use this plugin(included in the demo) otherwise download it from

Now I’ll explain how to use this plugin in any page

First of all,  include MS Ajax library(MicrosoftAjax.js) and (MSAjaxDownload.js) in the html head section

<script src="<yourpath>/MicrosoftAjax.js" language="javascript" type="text/javascript" />
<script src="<yourpath>/MSAjaxDownload.js" language="javascript" type="text/javascript" />

Now you have to create a simple javascript object  AjaxDownload. Use this object to perform download and attach events. It takes an optional single parameter "download url".

You can use any library on the client side to do this(I have used JQuery in the demo).

var dn = new AjaxDownload(<downloadurl>); // see the default.htm in the demo

The main methods of this object are as listed below (explore source code for other events, I’ll provide documentation soon)

1) add_onBeginDownload : fires before downloading.

   add_onBeginDownload(<javascript method>)

  You can call this method any number of times and attach different methods but they will be executed in the sequence.

2) add_onEndDownload : fires after Save Dialog opens or after an error response.

       add_onEndDownload(<javascript method>)

      You can call this method any number of time to attach multiple events.

3) add_onSuccess : fires after Save Dialog Opens(Successfully received response from server)

4) add_onError :  fires after an error. Error might be on the server or with an invalid url request.

5) EnableTrace : enables tracing to browser javascript console


6) GetParameters : Get the parameters associated with the URL. Return type is always NameValueCollection

7) SetParameters : Set the parameters associated with the URL. Accepts a NameValueCollection object which is defined in the plugin


8) AddParameter : adds a parameter to the parameter collection


9)  GetURL : Gets the URL

10) SetURL : Sets the URL

11) GetLastError: Gets the last error occured.

you can attach any javascript method to add_onBeforeDownload, add_onAfterDownload, add_onSuccess, add_onError events(refer MS Ajax handlers).

Example code

var dn = new AjaxDownload('http://<serverurl>/');
dn.AddParameter('fileName', 'xyz');
function beforeDownload()
alert('before download');
function afterDownload()
alert('after Download');
function onSuccess()
alert('file download success');
funtion onError()
var err = dn.GetLastError();
alert('file download error'+err);



I have configured a demo at



Files can be downloaded from Microsoft MSDN code library


Browsers supported

I have tested in the following browsers and it worked well

a) MSIE(6+)

b) Firefox(3.5)

c) Opera (9)

d) Chrome