Monthly Archives: February 2009

Firefox Go Button and Change Cursor

With Firefox 3, the “Go button” (circled in blue below) in the url bar is only available some of the time, depending on context.

I myself, prefer to have it there all the time. As Firefox is highly configurable, all I have to do is make a small addition to the userChrome.css file (located in C:\Users\[yourUserName]\AppData\Roaming\Mozilla\Firefox\Profiles\[profileNumber].default\chrome\).  Just add:

#urlbar[pageproxystate="valid"] > #urlbar-icons > #go-button {
	visibility: visible !important;
}

Note, if this is the first time you have configured these files, make a copy of the existing file userChrome-example.css and rename it userChrome.css.

Another little change I like in my configuration is to change the mouse cursor when it is hovering over a hyperlink which, when clicked, will open the target in a new browser window. This time, you need to make a change to userContent.css, which is in the same directory as userChrome.css. To do this, you just add the following:

/* Change cursor for links that open in new window */
:link[target="_blank"], :visited[target="_blank"],
:link[target="_new"],   :visited[target="_new"] {
   cursor:  crosshair;
}

Happy computerating!

AJAX Control Toolkit – Getting Started

Although I had trouble finding information about getting started with the AJAX Control Toolkit, it really is quite straightforward. I’ll break it down into steps:

  1. navigate to http://www.codeplex.com/AjaxControlToolkit , and click on the Downloads link (far right of the page).
  2. assuming you are running V3.5 SP1 of the .NET framework, download the dll only zip archive – AjaxControlToolkit-Framework3.5SP1-DllOnly.zip
  3. extract the contents of that archive into a directory on your machine. I created a directory called AJAX Control Toolkit in C:\Program Files, and placed all of the files from the archive in that.
  4. create a new Web Site in Visual Studio 2008.
  5. with your Toolbox visible, right-click on one of the headers in the Toolbox and click Add Tab, as depicted below:

    Adding a Panel to the Toolbox

    Adding a Tab to the Toolbox

  6. Name the new tab “AJAX Control Toolkit”.
  7. Right-click on the new heading and click “Choose Items”.
  8. Click the Browse button, navigate to the folder in which you extracted the AJAX Control Toolkit’s dll, select that file, then click open.
  9. Click OK. You should then see the new tab, which you just created, fill up with controls (from the AJAX Control Toolkit).
  10. Before using any of the controls, I recommend altering a default setting. At the top of the page, you will see the following new markup:
    <%@ Register assembly=”AjaxControlToolkit” namespace=”AjaxControlToolkit” tagprefix=”cc1″ %>

    Change tagprefix=”cc1″ to tagprefix=”AJAXControlToolkit”. This naming convention will make for easier maintenance and development.

To see the controls in action, there is an excellent walkthrough here, which highlights its features. You can run your own local version of that walkthrough if you also download the version of the Toolkit which has the source code included.

I hope others find this useful.

Convert SQL Server Money to Double

As you would be aware, SQL Server has a type called money. This is a type specifically designed for persisting monetary amounts.

The .NET framework does have the struct System.Data.SqlTypes.SqlMoney. And you could always use that as a field in a business object. But most developers will probably use the double type for monetary fields in their objects. So, this post is basically about how to read an SQL Server money type in, and convert it to a double.

Assuming you’ve instantiated an SqlDataReader called reader, the following code first checks to see whether the database field contains a null value (as is the case in the titles relation of the PUBS database). If null, it assigns 0.0 to the double variable, price. Otherwise, it reads in the variable and casts it to a SqlMoney type. SqlMoney has a method ToDouble() which then converts the amount to our double variable, price.

switch (reader.IsDBNull(3))
{
case true: { price = 0.0; break; }
default:
{
price = ((System.Data.SqlTypes.SqlMoney)reader.GetSqlMoney(3)).ToDouble();
break;
}
}

This, of course, is all happening inside a while loop, as the SqlDataReader iterates through the returned rows.

SQL Server – ROW_NUMBER

Recently, I needed to run a query which returned a numbered resultset. That is, I wanted one of the attributes in the resultset to serve no function other than to provide numbering for the returned tuples. To do this in SQL Server,  you can use the ROW_NUMBER() function.

It returns a sequential number for each row, starting at 1 for the first row. I refer to the first item in the following SELECT clause, which I ran on the MS sample database, PUBS:

SQL SERVER ROW_NUMBER routine

SQL SERVER ROW_NUMBER routine

This is a handy feature. But note, the row numbering is for the resultset that is returned. It is not the numbering of rows of the base relation.