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.

Tuesday, 4 November 2008

Friday, 17 October 2008

Intellisense not working in Visual Studio 2008

My Visual Studio 2008 stopped showing me intellisense the other day, unless I pressed Ctrl + Space. This was quite annoying as it is something I have come to rely on. After checking through all the settings, I stumbled across the "Statement Completion" options in Options -> Text Editor -> All Lanugages, these had all been unchecked, by what or how I don't know. I have now reset these options and Intellisense has returned.

Thursday, 16 October 2008

EntityName error

Full Page Xhtml validation error produced the following:

Error: An error occurred while parsing EntityName. Line 47, position 193. [47, 193]

This wasn't helpful, but with some tracking down I found out that two items contains the & character that hadn't been escaped.

Solution: Escaped all Xhtml characters in text fields.

Friday, 10 October 2008

Sitecore Page Editor showing input tags

Have you ever tried using the Sitecore page editor, only to find that when you click on edit you are presented with a screen full of tags:
<input id="fld_D2999F2E1BD441FA915E61CD65D09392_D3844EAD201947AF9D8C3BD340F05E8A_en_1_d2b36cfd9efc4068abcca16e543734c0_84" name="fld_D2999F2E1BD441FA915E61CD65D09392_D3844EAD201947AF9D8C3BD340F05E8A_en_1_d2b36cfd9efc4068abcca16e543734c0_84" value="privacy" type="hidden"><span class="scWebEditFrame" onmouseover="javascript:event.cancelBubble=true" style="display: none;"><span class="scWebEditFrameBorder"></span><span class="scWebEditFrameButtons"><span onmouseout="javascript:this.className='scWebEditFrameButton'" onclick="'javascript:return" onmouseover="javascript:this.className='scWebEditFrameButtonHover'" type="common" class="scWebEditFrameButton" title="Edit the related item"><img src="" class="scWebEditFrameButtonIcon" style="" alt="Edit the related item" border="0" /></span></span></span><span id="fld_D2999F2E1BD441FA915E61CD65D09392_D3844EAD201947AF9D8C3BD340F05E8A_en_1_d2b36cfd9efc4068abcca16e543734c0_84_edit" class="scWebEditInput" scfieldtype="single-line text" onkeyup="javascript:Sitecore.WebEdit.update(this,event)" oncut="javascript:Sitecore.WebEdit.update(this,event)" onpaste="javascript:Sitecore.WebEdit.update(this,event)" onmouseover="javascript:Sitecore.WebEdit.mouseOver(this,event)" onfocus="javascript:Sitecore.WebEdit.focus(this,event)" onblur="javascript:Sitecore.WebEdit.blur(this,event)" onclick=",event,'sitecore://master/{D2999F2E-1BD4-41FA-915E-61CD65D09392}?lang=en&ver=1');" contenteditable="true">privacy</span>

To resolve this issue, you have to make sure that you disable output escaping:
<xsl:value-of select="$field" escaping="yes" />

Wednesday, 8 October 2008

there is no attribute "name"

One of my favourite errors when trying to compile XHTML 1.0 Strict code. The fix is easy but one I always forget. Just add the following to the web.config within the <system.web> tag.

<xhtmlConformance mode="Strict" />

Thursday, 2 October 2008

Attach to w3wp worker process

As a web developer I often need to attach to the worker process. Wouldn't it be nice if I could use a simple keystroke rather than following the process of selecting Debug -> Attach to process -> Then selecting the w3wp.

The following post has a macro that will do this for you, I wont take the credit for this solution:

The post also tells you how to bind a shortcut to the macro. This tip saves me time and frustration.

When logging in with a domain account, you need to change the following:

Dim compName As String = WindowsIdentity.GetCurrent().Name
compName = compName.Substring(0, compName.IndexOf("\"))


Dim compName As String = My.Computer.Name

Tuesday, 16 September 2008

Form action defaulting to layout

When using Sitecore the form tag sometimes defaults to the layout page rather than the current page. This has caught me out too many times, so I thought I should note it down below.


  • Ensure that the App_Browser folder is in the root folder

  • Ensure that the App_Browser folder is not hidden.

Thursday, 11 September 2008

ISAPI Rewrite Disable option

One of my favourite rules in ISAPI Rewrite is the DisableRewrite as it allows you to turn of the rules for sites that don't require URL changes. This is useful as I run many sites side by side, some of which require this filter.
I can add the following line for each of the sites that doesn't need any rules.

DisableRewrite "default site"

Friday, 5 September 2008

Windows Server 2008 Send To menu

If like me, you like to customize your Send To menu so you can open documents in your favourite editor, Programmer's Notepad being one of mine. Then just paste this in to the run command:

The AppData folder is hidden by default, hence why I could't find it when I went searching.

Thursday, 4 September 2008

Triming strings to whole words in C#

This is a method that I have found useful whilst having to trim a string to a number of chars, whilst keeping whole words.

public string TrimToNumberOfChars (string originalString, int maxChar)
if (originalString.Length <= maxChar)
return originalString;

int lastSpace = originalString.LastIndexOf(" ", maxChar - 1);
if (lastSpace == -1) return "";
return originalString.Substring(0, lastSpace) + "...";

I hope other people find this useful.

Wednesday, 3 September 2008

Google Chrome

Google Chrome as been released as Beta this morning. This is a new browser built from the ground up. You can download it here.

This is a short cartoon comic that describes Google's approach to Chrome.

I hope to add more on this new browser as I play around with it.

Sunday, 29 June 2008

MCTS .NET Framework 2.0 Web Applications

This morning I successfully passed the MCTS exam 70-528. This is a milestone that I have been aiming for for over a year, from when I started studying for the MCTS early last year.

My next aim will be to complete the MCPD exam.

Thursday, 1 May 2008

TS .NET Framework - Application Development Foundation

Yesterday I successfully passed my first MCP exam.  I did the MCTS exam 70-536. This is the first of several exams as I aim to achieve my MCPD Web Developer certification.