ASP MVC Display Templates


So I’m still working on the Live CV website I’m creating in my spare time. The idea is pretty simple the web application will let users create an online CV, I’ll not get into the details of it until I’ve something more interesting to show.

Of course every resume needs a section on work experience and associated start and end dates. Now as a first step I’m just serving up my own CV before I get into all the exciting jQuery plugins etc. that' I’ve in mind.

Here’s how to format a date using a data template.


Here we see that I’m passing a template to the Html.DisplayFor<> extension.

Now I added a DisplayTemplates folder to my shared views (you could keep this folder local to your current view if you wish, but I wish to have it used throughout the project. Add a Partial view.


Here’s the content of my Partial view


Here’s the result.


CSS and custom jQuery filter selectors

I’ve discovered a nice set of jQuery filter selectors.

Take this example of selecting the checked radio button in a group






There are many many others, e.g. @contains, :disabled, :not(selector), :parent, :password, etc etc, more info in jQuery docs.

Watch that error stream with Java process executions


I’m executing a windows process from java and I was bitten by a nasty oversight in one of my project today.
Everything’s been working fine for some time, but today the application I’m calling started spitting out errors to the error stream.

However I’d not been reading the errorstream in my code and it appears to be the culprit for hanging the process execution.

I don’t really care about the error stream or even the inputsteam myself as the thirdparty application does its own logging.

The solution was a follows: I used a SteamGobbler class to purge the input and error streams. Hope this helps someone.





VS2010 C++11 Variadic Templates


If you’ve been following the changes in the C++11 standard you may have heard of Variadic templates. In layman’s terms: var arg template parameters.

Lets take c# to explain what we’re talking about: Take the Action generic delegate, there’ 16 of them! One overload for each parameter.


However in c++11 we should (when the compiler supports it) be able to use to indicate that we can have a variable number of type parameters ( I expect comes form java).

The long and the short of it is, they don’t work yet in vs2010 yet Sad smile


I wonder do they work in VS11? I’ll update this post once I get a chance to fire it up. I’ll also fire up my Linux machine and give the GNU compiler a whirl.

Stay tuned…


** update: Doesn’t work in VS11 either.

Silverlight Fluid Motion


You know what?
I love Silverlight!

The only reason I don’t spend more time in it is the ASP is more suited to non enterprise applications.
However tonight for you dear reader I’ve got an enterprise application (below)


(because every enterprise had an application that shows pictures Smile; yes really this was a requirement honest Be right back)


So you are writing a sliverlight app, or course you could code it all by hand.

In the last year, I’ve even met Silverlight/WPF programmers, lets call them Xamlers, that turn their nose up at using a designer, hey I’m sure it’s got it’s advantages and these people know XAML better than me, but IMO life is too short and programmers are too expensive to be living in notepad. Would you code your designer code in a windows forms app? not use scaffolding in MVC? etc etc..

For me Blend is blessing in disguise, I’m not sure the mythical devigner that is both an amazing designer AND an amazing coder (term coined by Scott Hanselman I think)  exists, but Blend does really help.


The application is simple, It selects some pictures in a folder and displays them in a list. When an item is selected in the list the picture should zoom out from the listbox item and scale to it’s full size.

Simple ey… yes of course (when you know how).



1. Create a new expression blend silverlight project


2. Add a sample datasource, some text and a picture




3. Drag the collection onto the page


4) Select details mode in the properties pane, and drag out property 2



If you were now to run your application you’d see that when you select a picture it appears in the main picture also. But our requirements were to slide out the picture from the list itself.

5) Select the big picture and drag fluid move behaviour onto it


6) Change the tag property to datacontext


Now do the same for the Itemtemplate


7) Drop a FluidMotionSetTagBehaviour onto the image part,setting the datacontext




That’s all that’s needed, you app should now run, animations and all.


I would provide the sample but I’ve used 11megs of pictures so it’s a little too big to expect you to wait for Smile

I might get some time to reproduce this app in html5, android, c++, java would be nice to compare and contrast.

Start blending xamlers!

MVC Mailer on NuGet


So have you ever found yourself doing this?


Well no there’s a nicer alternative whereby you can build up your mail in html.
Check out the MVCMailer package on Nuget.


PM> Install-Package MvcMailer
Attempting to resolve dependency 'T4Scaffolding (≥ 0.9.7)'.
Attempting to resolve dependency 'EntityFramework (≥ 4.1.10311.0)'.
Successfully installed 'MvcMailer 1.1'.
Successfully added 'MvcMailer 1.1' to TCF.

---------------------------READ ME---------------------------------------------------

Your default Mailer Scaffolder is set to Mailer.Razor

You can generate your Mailers and Views using the following Scaffolder Command

PM> Scaffold Mailer UserMailer Welcome,GoodBye

Edit the smtp configuration at web.config file before you send an email

You can find more at:





So it took me 2 hours (downloads on 2mbps included) to create an Android app in eclipse.

Wonder is that something I should be proud of giving I’ve been in software for nearly 15 years now…. 2 hours for a hello world… 


Listening to .net rocks and Xamarin podcast got me thinking, I really should see what’s involved in creating an Android app, after all I’m a registered Microsoft and Apple developer, I can create Wp7 apps in my sleep, I’ve even flirted with iOS, why not give Google and Android a shot.

I was going to install MonoDroid for VS2010, but hey i’m doing a hello world, no need for all this cross platformability. I’ve been doing a fair bit of java lately and eclipse doesn’t frighten me anymore so I just downloaded and installed the tools, and created the above app.. baby steps..

Any downsides? yes,, Now I wanna buy a Android tablet Who me?.

EF 4.1 Code First Database re-create


If you’ve upgraded to Entity Framework 4.1 you may have noticed the following no longer compiles. (the line of code that causes the database to drop and recreate on schema change).



DbDatabase.SetInitializer(new DropCreateDatabaseIfModelChanges<TCF.Models.TCFContext>());



HTML 5 Audio


So does your browser support the html5 audio tag when it comes to MP3s?

Browsers in order of my preference


IE9 – Nope



Firefox 5 – Nope, Moreover doesn't gracefully degrade to my fallback text!



Chrome 13 – Sure



Safari 5 – Arguably the best default experience


Try for your self and let me know how you get on (excuse the lack of the DOCTYPE, encoding etc.

It’s quote a catchy song, you’ll miss out if your browser doesn’t support it (or you are not familiar with view source Smile )

smart_ptr in java 1.7


Darn it but I’ve being doing a lot of Java recently and u know what, I’m no expert but it I think I could even a raise the rating on my C.V. at this stage. My first experience of Java was reading a book back in 2001 belonging to a student friend of mine, the book was lying about so picked it up and read it over the course of a week (yes I had an early addiction to technologies even though I was living in c++ land at the time). I ended up helping with one Final year project a java applet game suite if I remember correctly and in a JBuilder IDE.

Over the years I quickly forgot about my little affair with java and got deeper into c++ which I have to say I loved, around the same time I was having another affair (yes i was a slut) with Microsoft .net beta2. I can’t put my finger exactly on why c# won out for me, but I spent the next few years working on c++ and c#, Java was just something I always left to one side. I always though hey java will be easy, I’ve programmed in c#, same concepts, and moreover I knew c++, so well then c# or java are a walk in the part; while this I guess is partially true, but you’re not prepared you for the curve/slope/cliff you’ve got to climb to learn the IDE and the libraries needed these days.

I’m currently working for a data management company our products are written in java and .net. For the first two years I managed to live in the .net world but lately and mostly due to the success of some of our newer components I’ve been doing quite a lot of java, (a lot more than I ever expected). I’ve also started reading some good books on the subject and you know what I’m as likely to start a test application in Eclipse as I am in VS2010 these days (at least as far as the product components are concerned).

So what’s changed? Well for one the java language is evolving once again which is exciting; so to continue on my smart_ptr series of posts, we can now achieve resource cleanup with java 1.7 with the AutoClosable interface.

For .net people this will be very familiar to IDisposable and the using(var x = new IDisposableDerivedType())


   1:  File file = new File("input.txt");
   3:  InputStream is = null;
   5:  try {
   6:      is = new FileInputStream(file);
   8:      // do something with this input stream
   9:      // ...
  11:  }
  12:  catch (FileNotFoundException ex) {
  13:      System.err.println("Missing file " + file.getAbsolutePath());
  14:  }
  15:  finally {
  16:      if (is != null) {
  17:          is.close();
  18:      }
  19:  }
  21:  Java 7: Try with resources
  23:  File file = new File("input.txt");
  25:  try (InputStream is = new FileInputStream(file)) {
  26:      // do something with this input stream
  27:      // ...
  28:  }
  29:  catch (FileNotFoundException ex) {
  30:      System.err.println("Missing file " + file.getAbsolutePath());
  31:  }


We’re guaranteed that the

is.close(); gets called automatically for us. Have to say I'm a bit jealous that the c# team didn't think of the try() syntax over using.


Recent Tweets

Note: For Customization and Configuration, CheckOut Recent Tweets Documentation


<<  November 2017  >>

View posts in large calendar

Month List