Check out the Latest Articles:
Database Driven AJAX Gallery ASP.NET MVC

Hi All,

I found when I was attempting to learn ASP.NET MVC a wealth of knowledge for traditional request response web applications. However when it came to implementing AJAX functionality on my ASP.NET MVC application I struggled to find good examples. Most of the examples I found used the open source technology stack (Apache, PHP, MySQL) which whilst they could be understood and adapted it would have been nice to just have ASP.NET MVC examples.

I have been working on an AJAX Image Gallery example which can be located here: http://lightbox.jonathanstowell.com.

  • This example uses Lightbox a JQuery plugin which provides cool functionality whilst flicking through pictures.
  • I have also added a tab which uses FancyBox another JQuery plugin which allows scrolling of the gallery using a mouse wheel.
  • The example on the whole is database driven using a SQL Server database, storing Image Details and Image Categories.
  • It also uses Microsoft AJAX to provide a partial refresh when categories are selected and contains JavaScript code to reattach JavaScript handlers after an AJAX request to enable lightbox on returned images.
  • The example has file checking however this needs to be worked on as I think people can just change the file extension and basically fake .exe as .jpg.

I have disabled the upload on my live example however the provided source code allows uploads without having to alter anything.

If anyone has any questions feel free to comment and I will try to respond!

The theme is just a template to make it look nice as I’m not overly into the whole CSS and spending hours making things look pretty!

Source Code: Here



  1. Mark (Reply) on Monday 21, 2010

    Hi Jonathan, this is the coolest thing in MVC! I have been working on a website with galleries and i have been searching the net for a solution. I downloaded your sample here, changed the connection string and bingo!

    It is simply amazing! Thank you! Thank you!! Thank you!!!!!

  2. jonathan (Reply) on Monday 21, 2010

    :-) if you think this is the coolest thing. I suggest you look into fluent nHibernate, generic repositories and unit of work. That stuff is cool! Hopefully will get time to write about them soon!