Archive

Archive for the ‘c#’ Category

Working with vague dates (90′s, Sept 2000 etc.)

December 16th, 2009 fbis No comments

On a recent project I had to allow users to upload their memories. Memories are vague things and I had to enable users to upload and assign incomplete dates. They needed to be able to enter ‘The 90′s’ or ‘September 2000′ as well as complete dates ’1st Feb 2009′.

Read more…

Categories: c# Tags:

Get Rendered Html From a Control

November 16th, 2009 fbis No comments

Whilst working on the CMS I needed to be able to pass back the html a control will render when the user first adds it. The control doesn’t exist on the page yet as the sections are added via javascript. It was very easy to pass in StringWriter to the render function to get the html :)

Read more…

Categories: Asp.Net, c#, cms Tags:

CMS Framework – Update

August 16th, 2009 fbis No comments

Been a bit quiet round here lately but not because I’ve not been working on it ;) I’ve been using it for a project at work and converting a lot of my stuff to be compatible with it.  It’s running  a site atm and doing well.

Alpha State

Mainly in alpha because things may yet change but the following all work
Read more…

Categories: .net, Asp.Net, c#, cms Tags:

Simple way to create a singleton

April 28th, 2009 fbis No comments

Found this is microsoft official line on creating a singleton, much simpler than the normal GOF way :)

// .NET Singleton
sealed class Singleton
{
private Singleton() {}
public static readonly Singleton Instance = new Singleton();
}

Categories: .net, c# Tags:

Create controls dynamically from database

February 11th, 2009 fbis No comments

In my cms’ I usually have the option of creating controls from the database. This is just a simple use for reflection but allows me to add controls to page just by adding a new row.  If its one of my controls it supports a persistance system that allows the control to save and restore itself easily.

Read more…

Categories: .net, c# Tags:

Rendering Paths as a nested List

February 4th, 2009 fbis No comments

Keeping tree data in a database can be a nightmare. There are a number of techniques to achieve it but they are all either unwieldy on the sql side (multiple joins) or on the data side (binary trees). I needed an easy way to render a tree out in a single read from the db.
I achieved this by just having a path field in the table, ordering by it and then dumping it out with the following routine. Needs more work but ok for the mo :) Would need to change to writer instead of StringBuilder and I need to sort out the items that appear at the top (would appear under the folders in a treeview) Read more…

Categories: c# Tags: