Friday, March 27, 2009

Using jQuery to display the complete contents of a textbox when printing

When printing a web page that contains text inputs (a.k.a. a TextBox in ASP.NET) overflow content can be missing if the control isn't large enough. I've put together a small jQuery script that adds a span next to each text input that is usually hidden. The content of the span is then set to match the content of the input, including if the content is changed.

Note: In my case putting an overflow:visible; in the CSS wouldn't be sufficient.


            $('input[type="text"]').each(function () {
                    $(this).after('' + $(this).val() + '');
            $('input[type="text"]').change(function () {
                var textbox = $(this);
                var id = textbox.attr('id');
                $('#' + id + ' + span').each(function (){


  display: none;

 @media print { 
   display: inline;

Creating a temporary ASP.NET Profile provider in Session

See the ASP.NET forums: Profile provider that uses session?

Wednesday, March 25, 2009

Modal popup test using jQuery and jqModal

The following JavaScript link will display a modal dialog using jQuery and jqModal.

Show Modal

Test Modal This is a testing modal dialog

Monday, March 16, 2009

Getting the Date Builder module in Yahoo Pipes to accept a string

The documentation for the Date Builder module suggests it will accept text input and create a date time from it. But if you try to wire a Text Input straight to it you can't because the data types don't match. See the suggestion Date Builder Module Accept Text.

Wednesday, March 11, 2009

ScriptManagerProxy multple/split definitions.

I wasn't aware it existed, but the ScriptManagerProxy allows the ScriptManager to, for example, be defined in the master page and the have specific scripts and services added elsewhere via the proxy.

Monday, March 9, 2009

Removing ...\Live Mesh\GacBase\HoldingArea folder from WMP

I've been using Live Mesh to sync my music collection between several of my PCs. Recently I noticed that duplicates were appearing in my music library. I found the culprit was a Live mesh folder:

C:\Documents and Settings\UserFolder\Local Settings\Application Data\Microsoft\Live Mesh\GacBase\HoldingArea

With WMP 11 I removed the folder via "Category:Music > Library > Folder". I went with the "Delete from library only" option when prompted.

Thursday, March 5, 2009

Using the SqlDataSource in code

System.Web.UI.WebControls.SqlDataSource sqlDataSource = new System.Web.UI.WebControls.SqlDataSource();
sqlDataSource.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringKey"].ToString();
sqlDataSource.SelectCommandType = System.Web.UI.WebControls.SqlDataSourceCommandType.StoredProcedure;

sqlDataSource.SelectParameters.Add("ParamName", TypeCode.Int32, "1");

System.Collections.IEnumerable data = sqlDataSource.Select(new System.Web.UI.DataSourceSelectArguments());

System.Data.DataView dataView = (System.Data.DataView)data;

foreach (System.Data.DataRowView dataRow in dataView)

Getting a random Decimal in C#

I was writing some automated test cases the other day and I needed a System.Decimal that was different to the current decimal I had. Any old decimal would do, as long as it was different to the one I currently had. I thought, why no just grab a random one? Admittedly, I could just increment or decrement the one I currently had, but it bothered me that there didn't seem to be a easy way to get a random decimal (that includes Googling for some code that would do it for me).

I had a go at extending System.Random until is felt I was fairly close and then posted the question and my initial attempt to Stack Overflow.

See: Stack Overflow: Generating a Random Decimal in C#

It turns out there are a few gotchas with this. Firstly, getting a random signed (+/-) int from the random class requires careful consideration. Secondly, what kind of distribution of decimals was I actually after. There are multiple possible representations for the same number with the decimal class, so some numbers may come up more that others.

Sunday, March 1, 2009

Using a DSE XH4248 Data/Voice Splitter as a Data/Data Splitter

While it would make more sense to use a purpose made RJ45 Data/Data splitter you can make do with a Phone/Data Splitter and a custom made CAT-5e cable.

The Phone/Data splitter passes 1, 2, 3, and 6 straight through, so the first part of the Data/Data splitter is easy (naturally).

The phone part maps 4, 5, 7, and 8 to 4, 5, 3, and 6 respectively.

I made a custom cable to map the phone pins back to the data pins where:

  • Pin 1 (orange white) goes to Pin 3
  • Pin 2 (orange) goes to Pin 6
  • Pin 3 (green white) goes to Pin 5
  • Pin 4 (blue) goes to Pin 2
  • Pin 5 (blue white) goes to Pin 1
  • Pin 6 (green) goes to Pin 4
  • Pin 7 (brown white) goes to Pin 7
  • Pin 8 (brown) goes to Pin 8

Expressed as pins:

  • Pin 1 (blue white)
  • Pin 2 (blue)
  • Pin 3 (orange white)
  • Pin 4 (green)
  • Pin 5 (green white)
  • Pin 6 (orange)
  • Pin 7 (brown white)
  • Pin 8 (brown)

Taming the GrabASeat RSS - filtering for a single city

Flights from Air New Zealands GrabASeat can be a real bargin, but constantly checking their page (or setting it as your home page) isn't really practical.

The RSS feed helps with this, but I've found the signal to noise ratio to be really distracting. Flights to cities of interest usually get lost among all the other deals.

I found Yahoo Pipes to be a really useful for getting just the flights that interest me.

Basic Steps:

  1. Sign up for a Yahoo account.
  2. Browse to and click "Create A Pipe"
  3. Add a Fetch Feed from Sources to the working area.
  4. Set the Feed URL to
  5. Add a Filter from Operators.
  6. Set the filter to Permit items that match any of the following:
  7. Set the rule to item.title Contains Wellington
  8. Connect the Feed Fetch to the top of the filter and the output of the filter to the Pipe Output.

You should end up with something like:

Save the pipe, giving it a name, and then use the Run Pipe link at the top middle of the page. Now all that is left is to grab the output of your pipe. E.g GrabASeat Wellington Only RSS.

Another option is to search for an existing published pipe that matches your requirements. See For example, the Air NewZealand - Grab a Seat pipe uses the XML feed to get the price information and dates while filtering out the sold and coming soon listings.

Update 13 July 2009 - Since GrabASeat is now on twitter you can get a RSS feed with prices Grab A Seat RSS with prices