Troy Goode

BlogEngine Extension: Copy Code to Clipboard

Since I first started this blog I've been using Colin Coller's CopySourceAsHtml plugin for Visual Studio (which Guy Burstein updated for Visual Studio 2008's RTM). It was a nice little tool but as I started posting more and more code snippets to the blog I found myself wanting some additional features, specifically:

I found syntaxhighlighter on Google Code pretty quickly and was impressed. I'd seen it around on other people's blogs and loved the "copy to clipboard" feature, but I really wanted a server-side (or pre-posting) highlighter that would take some of the strain off the browser and wanted something with richer WLW integration.

After looking at a few more options I finally found Leo Vildosola's Code Snippet plugin, which matched up with all of my requirements except for the lack of a built-in "copy to clipboard" feature. With some help from clipboard copying javascript posted at WebChicanery I set out to build an extension for that would automatically tack on the copy feature to any code I posted via the Code Snippet plugin.

A few hours later, I present the CopyCodeToClipboard extension for! Below you will find an example of the extension displaying it's own code (mmm... dogfood) and the css I've used to style the code on my site. I've tried to make the extension css friendly so you can change it's presentation a great deal without modifying the code.

Contains all of the below files in one convenient package.


This is the actual extension and should be placed into your root/App_Code/Extensions/ folder.


The Css generated by the Windows Live Writer Code Snippet plugin, modified to fit into my blog's colors.


The Css I use to style the little red tab below each code area. This is what you would change to match your blog.


A Macromedia Flash file used to circumvent Firefox & Safari's nasty habit of blocking javascript from interacting with the clipboard. Created (as best I can tell) by Mark O'Sullivan of

Update (July 11, 2008):

A release of the Code Snippet plug hasn't been made since the last changes to its source was checked in (in late 2007), so I went ahead and downloaded & built the source. To install the plug place the two DLLs in the zip file from below into Windows Live Writer's /Plugins/ directory.