Friday, 2 January 2009

Blank <title> tags

If you are using ASP.NET and placehoders to render your metadata. You may notice that it will generate an empty <title> tag. This occurs when using XHTML 1.0 Transitional. I often use placeholders to control the content with in the title tag.

To overcome this, you can add the following in the head tag.

<head>
...
<title visible="false" runat="server"></title>
...
</head>

This turns the <title> tag into a server control, and the visible attribute prevents the blank title from rendering to the page.

Thursday, 1 January 2009

New Year = New Look

As it's the New Year I have decided to change the look of this blog. Also to note, my New Years resolution is to try and post here more often.

Happy New Year everyone.

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="http://www.blogger.com/sitecore/images/blank.gif" 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="javascript:Sitecore.WebEdit.click(this,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:
http://blog.lavablast.com/post/2008/01/Attach-to-Process-with-one-shortcut.aspx

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

UPDATE:
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("\"))


to

Dim compName As String = My.Computer.Name