I’ve made a small ASP.NET project showing a nice JQuery feature: .load()
The project is pretty stupid but the concept could be used for a lot of nice cases. Basically what I do there is that I use a Generic Handler (ashx) to display an image on a web page and while the image is getting loaded, you get to wait with a nice animated gif.
The project is splitted in two parts:
– a Generic Handler which writes the image on the http
– the JQuery client side code which fires the http request to get the image
The code of the Generic Handler is the following:
In the handler code, I am using a System.Threading.Thread.Sleep(3000) for demo purposes, just that we can see the loading process.
The JQuery scripts is defined as follows:
we show the imgLoading
we append a new image to a panel and we set the src with the address of our generic handler and it’s now that the best of JQuery takes place.
We use the .load on the newly appended image. This load event will get fired when the image will be totally loaded.
We then hide the imgLoading and use a .fadin to display our image.
Here is the the Visual Studio Solution zipped file : Project.zip