.NET

DPP_0106 Places to get good developer videos on 21 Jan 12 (2 comments)

A list of places to find videos about being a better developer. These are mostly about all the stuff I care about for work: writing good code, .NET technology and web dev.

Building javascript minification into MSBuild scripts on 29 Aug 09 (Add comment)

How to use a tool called Packer.NET to build javascript minification into a MSBuild script.

Restarting an IIS6 app pools using .NET on 09 Aug 09 (Add comment)

Two little code snippets for recycling IIS6 application pools in through .NET code.

To(): a handy way to convert strings to other types on 23 Feb 09 (3 comments)

The int.parse() method is one I use a lot in ASP.NET so I wrote a handy extension method called To using generic return types and a little reflection that makes converting all these string values to another type incredibly simple.

Improving the way ASP.NET handles 404 requests on 11 Feb 09 (2 comments)

How (and why) to make your ASP.NET site’s error handling better by returning the right response codes and redirecting to the error page without changing the url.

Svelte asp.net: avoiding <form runat="server"> on 08 Feb 09 (1 comment)

postbacks add a lot of weight to your page and you don’t always need them. Find out when you can do without them and how to use ASP.NET without paying the postback price.

Opening resx files in the xml editor on 04 Feb 09 (Add comment)

Defaults can never please everyone. There’s always someone whose workflow is a little different. That one developer who likes to use SeaMonkey to test their pages or that weirdo who prefers to edit resx files as a text file. I am that weirdo who likes to edit resx files as text files and rather than […]

Reducing viewstate on custom controls on 01 Feb 09 (Add comment)

One of the biggest waste I see in using viewstate is that it persists values that are already set in the aspx. These get set every time that the page runs and don’t need to be round tripped to the browser so that they will be persisted. I did a little experiment a while back […]

VS2008 SP1 – Microsoft replace my VS with a new one on 15 Aug 08 (Add comment)

I just downloaded VS2008 SP1. I just have to wonder what they’re patching that takes 831MB. The installed parts on my harddrive is only 700MB and surely they’re not making me download all the help, bitmaps and tools again? :) At least they have fast servers. :)

bored-skeleteon Saving server control properties to ViewState with custom attributes on 13 Aug 08 (6 comments)

Use custom attributes to take the tedious work out of creating server control properties that persist to ViewState. Declare a normal property and use an Attribute to tag it for storage to ViewState. See how to use reflection to see which properties need to be persisted.

New ASP.NET server control book for .NET 3.5 on 10 Jul 08 (Add comment)

Here’s a small plug for Joel who has just released a book on something quite dear to my heart, ASP.NET server controls. It’s called Advanced ASP.NET AJAX Server Controls for .NET Framework 3.5 and looks very interesting. I’m looking forward to adding it to my library. It’ll be nice to have an update to Nikhil’s […]

IButtonControl – any button will do on 30 Jun 08 (Add comment)

One nice feature of ASP.NET 2.0 is a new interface called IButtonControl. You can use it in a code behind to say a control needs to be a button but without actually saying whether it needs to be a Button, LinkButton, ImageButton or custom control button type. This is the type of thing that’s useful […]

Generic method return types on 05 May 08 (2 comments)

Generics aren’t just great for creating lists, they can also be used to return strongly typed information from a method. This example shows how to use a generic return type to parse any type of strongly typed primitive from a string.

One more thing to love about .NET generics: events with custom event args on 26 Apr 08 (Add comment)

Lists are a killer app for generics in .NET 2.0 but one of my favourite uses that gets less attention is declaring event handlers without having to create a custom delegeate. Imagine a situation where you want to pass a piece of custom information to the event handler so it can decide whether to cancel […]

Filtering DataView by DateTime on 05 Apr 08 (Add comment)

Just a little code snippet to remind me how to do date comparisons in a DataView using DataView.RowFilter. It needs # characters around the date and you seem to need to generate the date string using InvariantCulture: DataTable table = GetList(); table.DefaultView.RowFilter = string.Format(“date = #{0}#”, DateTime.Today.ToString(CultureInfo.InvariantCulture)); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind();

Validating your pages (the technical bit) on 13 Jan 08 (3 comments)

So hopefully now you’re convinced that validation is A Good Thing, have decided which doctype you’re going to use and have resolved never to use quirks mode again. Check, check, check. Ok people, that means enough of the talking. We are finally get to the technical stuff: how to validate pages! Validating using the W3C […]

Friends don’t let friends use quirks mode on 07 Jan 08 (2 comments)

Having a doctype in your webpage isn’t just about making your webpage validate. The most important practical reason to include one is to make sure the browsers are rendering in standards compliance mode. Most browsers have two modes for displaying webpages, standards mode and quirks mode. Webpages with a doctype are rendered using standards mode, […]

Choosing a doctype on 31 Dec 07 (13 comments)

So making sure that your webpages validate is important because it will make the pages render more consistently across different browsers, meaning you can spend less time debugging cross browser incompatibility and more time with your loved ones/down the pub/plotting world domination. But what are we going to validate against? The current most popular options […]

Sacrificing the validation goat to the browser gods on 27 Dec 07 (Add comment)

As a web developer, much of my working day is spent at the mercy of browsers. Sometimes it feels like I spend all my time coaxing useful work from bratty children who don’t like to get along. One of the important tools available for convincing the browsers to play nice is HTML and CSS validation. […]

Web Standards for ASP.NET developers on (Add comment)

Find out more about doing web standards compliant development if you develop in asp.net.

Accessing the contents of a URL through C# on 19 Aug 07 (4 comments)

Here’s a quick code snippet for accessing the contents of a url through C#. It’s nice and straight forward. You just need to use the HttpWebRequest and HttpWebResponse System.Net classes to request the url and then a StreamReader to grab the text from the response’s stream. The code should look something like this: HttpWebRequest request […]

What type are you really? on 04 May 07 (Add comment)

I had an interesting problem the other day. I had a situation where someone could pass a type to my method which could be potentially be a nullable type and I needed to know what the real type actually was. It turned out to be pretty easy to find out. The Type type has a […]

Frontpage extensions firewall on 28 Jan 07 (Add comment)

I wanted to set up front page extensions on my machine this week so I could access the web projects I wanted by typing in the url rather than having to pick from the list in IIS which is littered with experiments and sample projects. Lazy but worth it considering how often I have to […]

Using print stylesheets with ASP.NET themes on 16 Oct 06 (5 comments)

Using the @media css declaration to create a print stylesheet when you’re using ASP.NET themes to automatically include stylesheets.

An easier way to add toolbox components from assemblies on 10 Jun 06 (Add comment)

The other really cool thing that I learned this week was an easier way to install components from assemblies into the toolbar. In the past I always thought you had to do the slow and frustrating right click on the toolbox and then “choose items” to eventually bring up the “choose toolbox items” dialog after […]