Categories
Programming

Using CSS Selectors

It has been said about CSS that you can learn it in a day, but it takes years to master. Actually, it isn’t that hard to master if you have the right information to hand. Today I’m just going to dump a load of information on CSS selectors, which is the most common CSS question […]

Categories
Programming

HTML5 and Skip to Content Links

If you’ve done web development with any focus on accessibility, you will have found yourself creating “skip to” links on your web page. You may have noticed that I have these very links on this website and wondered what they are! The two links, “skip to navigation” and “skip to content” are of little use […]

Categories
Programming

JavaScript Short Tags and XHTML

Here is another JavaScript question I was asked yesterday, which was catching out a developer using XHTML and an external JavaScript file. Users of XHTML will be highly familiar with the use of the “short tag” (this isn’t when you sell a load of tags you don’t yet have, speculating that the value of the […]

Categories
Programming

JavaScript Includes and Rewritten URLs

I recently answered a question on a forum about JavaScript includes in ASP.NET MVC and as the question came up again today, I thought I’d share the answer with the world. The issue that people are coming up against is that they have a script include with a relative path to their script file. Because […]

Categories
Programming

Always Use Those Curly Braces

I write a lot of code in a lot of different languages – but there is one common rule I apply to all of them… when you use an “if” block, always put in the curly braces even if you don’t need them. Many errors are related to violations of this simple style rule. I […]

Categories
Programming

Get NMock2 to Return Out Params

There are plenty of mocking frameworks out there, with Rhino Mocks and Moq leading the way. Personal preferences aside, I am currently working on a project that is using NMock2 for mocking and found that the following feature isn’t very well known. In the process of adding unit tests to some legacy code, before I […]

Categories
Programming

AJAX Ready State Codes

If you are hand-cranking an AJAX request, you’ll be looking for a Ready State of 4 and a Status of 200. But what other Ready State Codes are there and what do they mean? request.onreadystatechange = function () { alert(“readyState: ” + request.readyState); }; 0. Uninitialized 1. Set up, but not sent 2. Sent 3. […]

Categories
Programming

Auto Load Your PHP Classes

In PHP you can create classes to organise your code and represent objects that you want to pass around. This has long been a feature of other languages and was a fundamentally important step forward for PHP. There was one thing, though, that I didn’t like about PHP classes. If I wanted to instantiate a […]

Categories
Programming

The Specified Directory Service Attribute or Value Does Not Exist

“The specified directory service attribute or value does not exist” If you’ve come across this problem while trying to use Active Directory, you may well be dancing the double-hop. This issue can occur when you switch on “Integrated Windows Authentication” in IIS and then try to get some information from Active Directory for the logged-in […]

Categories
Programming

JavaScript and Noisy HTML

I was answering a question on a popular coding forum and it once again highlighted the age old problem of terribly bad JavaScript. This was the HTML code in question: <a id=”image1″ href=”#”><img src=”image.png”></a> And there was a bit of JavaScript adding an onclick event to the anchor tag. An innocent looking example. An anchor […]