Chris List send me an email about the implementation used in Right-aligning numerical fields in CRM views. Instead of using a script to dynamically change the styles at runtime, he suggested modifying the styles in the header instead. I also worked on this topic, but haven't had updated the article yet. The following combines Chris' approach and what I have done since posting the initial article.

How it works

This is an unsupported customization!

All main views are handled by the hompage.aspx file in the /_root folder. The standard implementation is:

<%@ Page language="c#" Inherits="Microsoft.Crm.Web.EntityHomePage" CodeBehind="Microsoft.Crm.Application.Pages.dll" %>
<%@ Register TagPrefix="mnu" Namespace="Microsoft.Crm.Application.Menus" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Register TagPrefix="cnt" Namespace="Microsoft.Crm.Application.Controls" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Register TagPrefix="loc" Namespace="Microsoft.Crm.Application.Controls.Localization" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Import Namespace="Microsoft.Crm.Application.Pages.Common" %>
<html>
<head>
<cnt:AppHeader runat="server" id="crmHeader"/>

<script language="JavaScript">

function window.onload()
{
HandleBackButtonIssues(_currentTypeCode);
}

</script>

</head>

<body class="stage">

<table class="stdTable" cellpadding="0" cellspacing="0">
<tr height="34">
<td>

<table class="homepage_table" width="100%" cellpadding="0" cellspacing="0">
<col width="60%"><col width="20"><col><col width="40%">
<tr>
<td><cnt:AppQuickFind id="crmQuickFind" runat="server"/></td>
<td align="center"><span class="homepage_span">&nbsp;</span></td>
<td nowrap class="homepage_td"><span style="color:#000000;font-weight:<%= CrmStyles.GetFontResourceAttribute("General.Bold.font_weight") %>;"><loc:Text ResourceId="Web.View_Label_70" runat="server" ID="Text1"/></span></td>
<td><cnt:AppViewSelector runat="server" id="crmViewSelector"/></td>
</tr>
</table>
</td>
</tr>
<tr height="25">
<td><mnu:AppGridMenuBar id="crmMenuBar" runat="server"/></td>
</tr>
<tr>
<td ><cnt:AppGrid runat="server" id="crmGrid" /></td>
</tr>
</table>

</body>
</html>

Columns are simple TD elements and the values are wrapped inside a NOBR tag. Numerical columns have a class name of "num", so a typical numerical value has the following HTML representation:

<td class="xxx" ...><nobr class="num">500,00 €</nobr></td>

Date/Time columns have a class name of "datetime". No other classes seems to be used. However, lookup columns can be identified as well. They are wrapped in a span element with a class name of gridLui.

To change the style of number, date and lookup columns, place the following into the homepage.aspx. It has some consequences though and I'm telling you about it later. But first I want to show you the code:

<%@ Page language="c#" Inherits="Microsoft.Crm.Web.EntityHomePage" CodeBehind="Microsoft.Crm.Application.Pages.dll" %>
<%@ Register TagPrefix="mnu" Namespace="Microsoft.Crm.Application.Menus" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Register TagPrefix="cnt" Namespace="Microsoft.Crm.Application.Controls" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Register TagPrefix="loc" Namespace="Microsoft.Crm.Application.Controls.Localization" Assembly="Microsoft.Crm.Application.Components.Application" %>
<%@ Import Namespace="Microsoft.Crm.Application.Pages.Common" %>
<html>
<head>
<cnt:AppHeader runat="server" id="crmHeader"/>

<script language="JavaScript">

function window.onload()
{
HandleBackButtonIssues(_currentTypeCode);
}

</script>

<!-- BEGIN CUSTOM CODE! -->
<style type="text/css">
    NOBR.num {
        text-align:right;
        color: Blue;
    }

    NOBR.datetime {
        text-align: center;
        color: Maroon;
    }

    SPAN.gridLui {
        color: Maroon;
        font-weight: bold;
    }
</style>
<!-- END CUSTOM CODE! -->


</head>

<body class="stage">

<table class="stdTable" cellpadding="0" cellspacing="0">
<tr height="34">
<td>

<table class="homepage_table" width="100%" cellpadding="0" cellspacing="0">
<col width="60%"><col width="20"><col><col width="40%">
<tr>
<td><cnt:AppQuickFind id="crmQuickFind" runat="server"/></td>
<td align="center"><span class="homepage_span">&nbsp;</span></td>
<td nowrap class="homepage_td"><span style="color:#000000;font-weight:<%= CrmStyles.GetFontResourceAttribute("General.Bold.font_weight") %>;"><loc:Text ResourceId="Web.View_Label_70" runat="server" ID="Text1"/></span></td>
<td><cnt:AppViewSelector runat="server" id="crmViewSelector"/></td>
</tr>
</table>
</td>
</tr>
<tr height="25">
<td><mnu:AppGridMenuBar id="crmMenuBar" runat="server"/></td>
</tr>
<tr>
<td ><cnt:AppGrid runat="server" id="crmGrid" /></td>
</tr>
</table>

</body>
</html>

The inline styles are applied to the CRM data inside of the application grid. It's much cleaner this way compared to the previous implementation and it also after refreshing a view - this was a problem with the script-based solution. Here's an example of such a modified view:

It doesn't work in associated views and it doesn't work in other areas as well, but it does the trick in general.

Disadvantages

The solution is easy and it really helps in our daily work. However, there are two disadvantages. It's an unsupported customization and though it really doesn't do anything bad and it's easy to remove, it does change a CRM source file, leaving your CRM system in an unsupported state.

The second issue is that upcoming updates may not be applied to your system correctly. If you "patch" a CRM file yourself, then a hotfix or update rollup may not update the files you have changed. I noticed this behavior in Visual Studio 2008 update packages as well: files that have been modified (modification date different than creation date) are not replaced during an update.

If you change the homepage.aspx file and you apply an update to your system that includes a newer version of the homepage.aspx file, then it may not be copied to your CRM directory. Keep that in mind before changing anything in your CRM web.

Anyway, I'm very pragmatic and am breaking rules whenever I think that it makes sense. As you know the consequences, it's now up to you to use it or not.

Update 22.07.2008

Samantha Jones pointed out that you can also change the CRM css files instead of the homepage.aspx. Her article shows where to put the styles in order to have it applied globally in CRM. This is even better than doing it inline and should work in all views.