posts - 916, comments - 758, trackbacks - 11

My Links



Post Categories

Misc. Coding

Code Snippets

WPF: Byte Array to Bitmap Value Converter

I wrote this for use in a little project but as I'm no longer using it, I though I'd stick it on here for anyone who wants it. Essentially, this allows you to take a byte Array (in my case, in the File property of my ThumbnailViewModel) and get it back as a BitmapImage for use in DataBinding... It also has the property of accepting a parameter which lets you specify the size of thumbnail to use (ThumbSize). Here, I actually have multiple ThumbNails (in the List<ThumbNailViewModel>) and select one using the parameter. Given this resource string and...

posted @ Saturday, February 13, 2010 3:10 PM | Feedback (0) | Filed Under [ Code Snippets XAML WPF ]

WPF for the Web guy…a story of pain, despair and learning

Well, OK I'm over dramatizing it a tad :) As you may have noticed from my last post I've started working of some stuff which is outside my comfort zone. I recently joined a company called cozwecan,working for a chap named @RobertTheGrey, the first project we're working on is a photo sales know kind of like Getty Images / Smugmug / Flickr except for direct photographer-customer sales. As the only full-time developer (so far!)  I've been tasked with building the vast majority of the applications (be they web, desktop, etc...) which we need for the business to work. ...

posted @ Wednesday, January 20, 2010 12:53 PM | Feedback (2) | Filed Under [ Code Snippets Multi-Threading cozwecan ]

Image Utilities

Thought I'd just post some dumb little utility classes that I had hanging about in my code repository (and always end up trying to find). They're just little utility classes for finding out image format / extensions / content types for various images...(and before any smartass pipes up, yes much of this info is in registry...but this is intended for use where I can't access that) public static class Imaging { public static string GetContentTypeByImageFormat(ImageFormat format) { ...

posted @ Thursday, January 07, 2010 5:41 AM | Feedback (0) | Filed Under [ Code Snippets ]

ASP.NET 4 Beta 1: WebForms Routing extension methods

When we were adding WebForm routing to ASP.NET 4 Beta 1, we didn't have a chance to add in a couple of methods which make working with Routes and Web Forms a lot easier! Note: the code below is 'similar' to that which we're adding ASP.NET 4 Beta 2, *that* code will be of much higher quality however, this is a sample only! 1: using System; 2: using System.Collections.Generic; 3: using System.Linq; ...

posted @ Tuesday, May 19, 2009 1:23 PM | Feedback (5) | Filed Under [ Code Snippets ASP.NET 4.0 ]

GridView with no Inline Styles (mostly!)

UPDATE: I've put the entire CSS Manager source including this control on my Codeplex site, you can get it here. This has been a bit of an obsession for the past couple of days...I wrote previously about a little CSS combining control which I'm working on. As part of this I wanted to experiment with ways of optimizing our current controls. Well, I thought I'd throw this up (in both meanings of the term) here for some quick reference. Again, not fully implemented, just an experiment. You'll also quickly notice that there's some other gubbins missing; like...

posted @ Friday, May 08, 2009 11:48 PM | Feedback (1) | Filed Under [ ASP.NET Code Snippets ]

Little hack: CSS Combiner / Minifier ASP.NET Control

CAUTION: When I say hack I mean it...this is in NO WAY production's just a sample at this stage. If it causes your dog to explode, don't blame me! I thought I'd throw a work in progress online for people to have a play with. This is one of my little pet projects (I'm not allowed to write code at work...not a dev as I'[m always reminded!). So, what does it do?   Well, one of the major performance issues for current websites is the number of...

posted @ Friday, April 24, 2009 1:59 PM | Feedback (3) | Filed Under [ ASP.NET Code Snippets ]

Premature optimization and user pet project and CSS Sprites

One of the themes I'm looking at for vNext of ASP.NET is the optimization of sites by reducing the number of server requests required for a single page. A new classic in the area of improving the perceived performance of your sites by reducing the number of server roundtrips is Steven Sounders book 'High Performance Websites'. Steven's book is very small, very readable and probably the best book on anything to do with the web that I've read in years. This book was a huge revelation for me...I spent most of my coding career writing the slickest, highest performing code I could...and frankly...

posted @ Friday, July 11, 2008 7:54 PM | Feedback (1) | Filed Under [ .NET ASP.NET Code Snippets ]

Dumb little recursive, generic FindControl method...

Doing some app building and I needed to use FindControl to manipulate a control in the OnItemCreated event in a Repeater...well, to save a bit of typing I came up with this extension method:   namespace Presentation {     public static class ControlHelper     {         public static T FindControl<T>(this System.Web.UI.Control root, string controlId, bool recursive) where T: System.Web.UI.Control         {             if(root.Controls!=null && root.Controls.Count>0 && root.FindControl(controlId) != null)             { ...

posted @ Wednesday, May 14, 2008 11:32 AM | Feedback (1) | Filed Under [ ASP.NET Code Snippets ]

Grrr...poor use of singletons and a very cool Generic Singleton pattern!

I posted earlier that I'm switching to, as part of this I've been fiddling around with the code (as is my way..I'll contribute back to the source when I've finished). One of my major pet hates is poor use of the singleton pattern, especially as there's a definitive article on the pattern in .NET and how to do it well. It's actually likely that this pattern is overkill in this case and a ReaderWriterLockSlim could be better (though it has it's own problems) . Anyway, on the assumption that a Singleton is the best choice here, let's look at...

posted @ Wednesday, April 30, 2008 10:42 PM | Feedback (7) | Filed Under [ .NET Code Snippets ASP.NET Tips ]

Work in progress, Response.RelativeRedirect

Inspired by this post, only covers simple cases but it's a start. Essentially this is an extended version of Response which only allows redirection to pages within the same allows /default.aspx, does not allow I've also ripped off a member of my team's excellent work on Response.Redirecting to a new window. This method uses extension methods, to use it just drop the file in App_Code and Response gets two new members. Oh and it's incomplete because I didn't account for encoded / obfuscated URLs...I'll update when I do...   using System; ...

posted @ Wednesday, April 23, 2008 3:00 PM | Feedback (0) | Filed Under [ ASP.NET Code Snippets ]

Full Code Snippets Archive

Powered by: