Posts for November, 2004


I found a couple of interesting articles about ASP.NET and web standards when I was looking for information about seperating presentation and business logic in ASP.NET using XML. The guy from ASP.NET resources makes the argument that it’s not economically viable to put the resources into developing ASP.NET applications that return properly compliant XHTML. I […]
Published in ASP.NET on Friday, November 26th, 2004

Automatically initialising Javascript objects that require the DOM

One of the problems I had when I first started creating Javascript widget objects is that I always needed to create the object in two stages. First I’d actually create an object with the correct parameters, then I’d register a piece of script that actually did all of the initialisation code that accessed the DOM […]
Published in Javascript on Tuesday, November 23rd, 2004

Keep it simple

Adam Bosworth talks about how the value’s in the content not the technology.
Published in Web development on Tuesday, November 23rd, 2004

Treating a mapped drive as local

I’ve been having to keep my NUnit tests on my local drive because the network drive the rest of my project lives on doesn’t have enough permissions to run them. This is bad because I can’t keep the tests with the code they’re testing and I keep forgetting to back them up. The PC I’m […]
Published in Sysadmin on Monday, November 22nd, 2004

A DOM friendly way of getting values from radio buttons

The problem with radio buttons is they don’t work like ordinary form elements. You can’t just apply an ID to a radio group, use document.getElementById() to get a reference to it and then query the value. This means to find the value of my radio group I’ve had to use the old fashioned document.forms[0].groupName method […]
Published in Javascript on Wednesday, November 17th, 2004

C# syntax for creating an abstract property

public abstract int GetX { get;}
Published in .NET on Wednesday, November 17th, 2004

protected internal access modifier

Here’s how you create a property (though it could be variable, method or I think even class) that can be see by things that subclass the object it belongs to and things that are in the same package: protected internal object myProperty { get { return m_property; } set { m_property = value; } } […]
Published in .NET on Wednesday, November 10th, 2004

Loading and saving registry information in C#

Saving info to the registry for the currently logged in user: RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey"); key.SetValue("MyKeyValue", "Some value"); Loading the same info from the registry: RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey"); if(key != null) { string keyValue = (string) key .GetValue("MyKeyValue"); } Reference: RegistryKey Class MSDN documentation
Published in .NET on Monday, November 8th, 2004

Formatting an XML string in C#

Here’s a nifty trick if you’ve got a chunk of XML you want to format nicely: XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlStringVariable); MemoryStream memoryStream = new MemoryStream(10240); xmldoc.Save(memoryStream); string formattedXml = Encoding.ASCII.GetString(memoryStream.GetBuffer()); memoryStream.Close();
Published in .NET on Friday, November 5th, 2004

Defining the entry point for a C# application

This is the C# equivalent of the Main(String[] args) method in Java: [STAThread]static void Main() { Application.Run(new MyStartupClass());} This code usually goes in the class that defines your first windows form.
Published in .NET on Friday, November 5th, 2004

Writing text files in C#

My quick-start file writing example for those who go months between needing to write a file. StreamWriter writer = new StreamWriter(filename, false); writer.Write("some text"); writer.Close(); I remember it being harder than this.. Reference: Streamwriter documentation
Published in .NET on Friday, November 5th, 2004

An advantage of C# properties

Just found a good reason to use properties in C# rather than public variables: they’re much easier to debug. When I was getting an unexpected value in the variable, I put a break point in the property and was able to really easily find out where it was being set.
Published in .NET on Thursday, November 4th, 2004

Raising custom events in C#

First you need to declare an event in the class that’s going to raise the event. This is just like declaring a normal variable: public event EventHandler MyEvent; Then you need a method that’s going to be called to raise the event. This goes into the same class that you just declared the event in. […]
Published in .NET on Wednesday, November 3rd, 2004

Designing a data access layer

Goals: 1. Have the rest of the application interact with the data sources only through an interface 2. Make it so the rest of the application doesn’t have (even can’t) to know how the data sources work 3. Make it easy to change the DAL without affecting anything else 4. Keep all of the relevant […]
Published in Programming on Tuesday, November 2nd, 2004

Must be getting old..

You know I just realised I don’t really need to write my own blog software. I’ve done news scripts before, I wouldn’t really be learning anything new. The world already has a 1:3 blog software to web developer ratio. I can think of things that will be much more interesting and rewarding to do with […]
Published in Programming on Tuesday, November 2nd, 2004