Archive for November 2009

ASP.Net MVC RadioButton extension method and accessibility

8 November 2009

When ASP.Net WebForms (as they’re called now) came out, the ability to make accessible websites out of the box was almost impossible. From simple mistakes such as always giving every image tag one blank space in the alternate text attribute to not providing any way of linking the standard Label tag to HTML Input tags it was an accessibility mess. Things were tidied up slowly with different releases and you could always write your own controls to render accessible content which was the solution I went with.

However it seems little has been learnt in the rush to get MVC to market. The extension method for creating radiobuttons, which is how most new developers are going to code, does not have an ID attribute input. As such, there is no simple and memorable way to connect a label to the radiobutton and give meaning to vision impaired web surfers. Whilst it’s true that you can specify an HTML attribute in one of the overloads to overwrite the ID, by not adding it as default attribute, new users are going to continue down the route of poor accessible HTML coding ad infinitum. I think it would’ve been nice if all of the RadioButton extension methods had a name and *Group* attribute to encourage intelligent thinking around the HTML being produced.

So, when you’re coding radiobuttons, make sure you pass in an ID attribute to the method so you can link your labels correctly.

<%=Html.RadioButton("apples", 5, new { id = "aFive" })%>
<label for="aFive">Five apples</label>

Posted in Technical | 2 Comments »

NHibernate hbm.xml file intellisense in Visual Studio 2008

5 November 2009

I was wanting the power of Visual Studio’s intellisense to enable me to be more productive with generating NHibernate’s hbm.xml config files. I’d seen a number of different ways of doing it but none of them seemed to be super reliable. I wanted it so that when I typed the xlmns namespace attribute, the NHibernate XSD files appeared in Visual Studios dropdown list of available XSDs.

To do this is remarkably simple. Copy the two files named “nhibernate-configuration.xsd” and “nhibernate-mapping.xsd” from your NHibernate download zip into “C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas”. Obviously your exact path may vary but it is the xml\schemas folder that you need. If you have your project open, save, close and reopen it (to refresh Visual Studio’s cache) and voila, you have intellisense working for your NHibernate config files.

Posted in Technical | 1 Comment »