Thursday, 4 December 2008

Label reference to non-existent ID

This can occur when you create a label tag to point to the ID of a text box.

<label for="email">Email address</label>
<asp:TextBox ID="email" Text="" runat="server"/>

But at render time ASP.NET changes the ID to something like ctl08_email

This can be rectified by replacing the following in the 'for' attribute.

<label for="<%= email.ClientID %>">

ASP.NET will now place the TextBox ID in the labels 'for' attribute.

Tuesday, 2 December 2008

Visual Studio Gridlines

You can place vertical gridlines in to the text editor for Visual Studio. This is useful if you have strict coding standards involving line lengths.

Open the registry
[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\9.0\Text Editor
Add a new string value and call it Guides
Add in the value RGB(191,205,219) 16, 80, where RGB is the colour, followed by up to 13 positions of the line. The above example is place a line after the 16th and 80th character.