Wednesday, 10 June 2009

Turn on IIS 6 Compression for CSS and Javascript

  1. Enable HTTP Compression
    1. Open IIS Manager
    2. Right-click "Web Site" and select "Services" tab.
    3. Check "Compress Static Files"
    4. Click "Okay"

  2. Specify that "js" and "css" file should be compressed by changing the metabase. By default, IIS 6.0 is set up to compress htm, html, and txt files.
    1. Open a command prompt
    2. cd to C:\Inetpub\AdminScripts (assuming the default location)
    3. run this command (you can change the list of extensions, but only specify static, compressible files here):
      cscript.exe adsutil.vbs set w3svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "js" "css"

  3. Restart the World Wide Web Publishing Service

Monday, 8 June 2009

Add an image to an a tag with no underline

I had a task to add the media mime type icon to a list of document links. The problem was the client didn't want to have the icon underlined. The solution I used was taken from StackOverflow:

Updated the CSS to include

.no-underline {
text-decoration:none;
}
.underline {
text-decoration:underline;
}
And generate the link the XHTML as

<a href="#" class="no-underline">
<span class="underline">
Link text
</span>
<img src="/icon url" alt="alt" />
</a>

Wednesday, 3 June 2009

Sitecore 6 RSS Module Error

Have you tried using the RSS module in Sitecore 6 only to get the following error when inserting a new RSS feed?
Item "/sitecore/template/Branches/RSS Feed" is not a template.



The solution to this is as follows.

  • Open the Content Editor
  • Select the RSS Feeds node
  • Select Configure / Assign
  • Remove the RSS Feed item
  • Add the RSS Feed from the sitecore/templates/RSS Module

You will also need to delete the Example feed.

Wednesday, 13 May 2009

Autofix DB users

NOTE! The resolution in this post is being deprecated, please use this post for an updated approach.

When you are copying databases across servers, the SQL users will lose their mappings.
Instead of deleting and recreating, you can use the autofix login script. This will try to match up the user on the database with one that is already available on the server.
EXEC sp_change_users_login 'Auto_Fix', 'username', NULL, 'password';
If the user doesn't exist, then the script will create a new user with the supplied password.

Friday, 17 April 2009

CheckBoxList - startIndex cannot be larger than length of string

Have you ever created a custom checkboxlist and then recieved the following error when you submit the form if any of the check boxes are selected?

startIndex cannot be larger than length of string.
Parameter name: startIndex
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7492915
System.Web.UI.WebControls.CheckBoxList.LoadPostData(String postDataKey, NameValueCollection postCollection) +60
System.Web.UI.WebControls.CheckBoxList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +346
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743



I have and it took quite some Googling to find a solution. The error is caused by the checkbox name not following the Microsoft.NET convensions, i.e. ctl13$ctl02$
The solution was to update the name to use UniqueID + $ + index on the end.

protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
{
var labelID = UniqueID + "$" + repeatIndex;
writer.Write(string.Format("<input value=\"{1}\" id=\"{0}\" name=\"{0}\" type=\"checkbox\" {2} />",
labelID,
Items[repeatIndex].Value,
Items[repeatIndex].Selected ? " checked=\"checked\"" : ""));
}

Thursday, 2 April 2009

Hidden windows?

I use a dual screen display in work, but when I remote in from home I only have one. Sometimes I have left windows open that seem to appear still on a second monitor. To view these hidden windows. Select the window in the task bar and enter:
Alt + Space bar + M
and then use your arrow keys to move the window in to view.

Monday, 30 March 2009

TFS: Change computer name

We have just had to update the names pf our PC to align to a new company policy. One of the things that this broke was the mapping of TFS workspaces. A fix for this the following command.

Using the command promt, navigate to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

Now, using the tf.exe tool
tf workspaces /updateComputerName:MyOldComputerName /s:http://TFServer:8080

Tuesday, 24 March 2009

MCPD Web Developer

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

Thursday, 19 March 2009

Sitecore Performance

We have noticed some slow performance using Sitecore recently on some of our websites. One of the options discussed on the SDN forum is to disable the performance counters. I've tried this approach and the improvement in performance is noticeable.

So if you are also having performance issue try disabling the performance counters. To disable the performance counters change the following line in the web.config to false:
<setting name="Counters.Enabled" value="true" />

Monday, 9 March 2009

Sitecore alias button

I was trying to give a small group of users access to the Alias button, but couldn't find out how to accomplish this, I had given them access to the ribbon, chunk and command but it still wouldn't show up How did I fix this.
  1. Log in to the master database
  2. Under sitecore/system
  3. Unprotect the alias folder
  4. In the security editor, give the required role read, write, create, delete and rename privileges.
  5. Protect the alias folder.