jQuery.serializeArray() works also outside a form


Quote from jQuery docs: "Note that serializeArray() only works on form elements, using this method on another element will not work."



However, this is wrong, at least in 1.4.2 because I’m using the function to send some params to a controller this way:

<input type="hidden" id="LicenseId" name="LicenseId" value="" class="markerDTO" />
<input type="hidden" id="marker_Color" name="marker.Color" value="" class="markerDTO" />
<input type="hidden" id="marker_Id" name="marker.Id" value="" class="markerDTO" />

The 3 fields are not included in any <form></form>

var oo = $(‘.markerDTO‘).serializeArray();

            url: ‘-my-url-‘,
            dataType: ‘json’,
            data: jQuery.param(oo),
            complete: function()
                var licenseId = $("#LicenseId").val();
                var color = $("#marker_Color").val();

                $(‘div.marker-color[license-id=’ + licenseId + ‘]’).css(‘background-color’, color );

                // unblock when remote call returns


Also it works with just one input:

var oo = $(‘#LicenseId’).serializeArray();

How to lose an interview: ask about the Joel’s test

Recently I had an interview for a job, for an Austrian company, involved in banking automation.

They are looking for .NET software developers for the Bucharest office.

So I passed the first technical interview at the recruiting company and I went on to discuss with the technical manager and the boss.

They asked, I answered pretty well, except for a couple of questions.

Everything seemed alright for them and for me too.

At the end, when I was asked about my questions about the company, how they work and so on, I pulled-up a piece of paper with Joel’s test.

I like to consider the Joel’s test like a smoke test for software companies. You can find the details here: http://www.joelonsoftware.com/articles/fog0000000043.html

The guy seemed a bit shocked but he answered the questions. And the answers made me happy.

I thought, hey, this is a nice company, I might like it here…


But… a couple of days later I got a phone call from the recruiting company saying that the answer was negative, but not for technical reasons but because they were very displeased by my questions, from the Joel’s test.


The conclusion? Be very careful with what you ask your potential employer. 😉

Where’s the bug?

Where’s the bug?

public virtual void RemoveOfferItems()
    for ( int i = 0; i < offerItems.Count; i++ )
        OfferItem offerItem = offerItems[i];
        log.Trace( "offer item: {0}, {1}", offerItem.Id, offerItem.Description );

        offerItems.Remove( offerItem );

But don’t write a test for this…

NVelocity over Spark

Ever since I started to build web applications using Castle Monorail, I used NVelocity as view engine.

I know many think is not powerful enough and that there are view engines better than NV. Still, for our projects, NV was just enough.

For Storingen project I decided to user Spark v1.0, a new view engine built initially for MS-MVC. Now that the project was launched to production, I though I’d share some thoughts on Spark vs. NVelocity.

1. For a view engine having the slogan “less is more”, Spark is way too verbose.

Compare this:


<test if="PropertyBag['actionResult'] !=null">
    <p style="color:red"> ${PropertyBag['actionResult']}</p>


#if ($actionResult)
    <p style="color:ff0000"> $actionResult</p>

2. Try to debug this:

Dynamic view compilation failed.

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\my.project\f6ea7153\3708dd9104e947bd8207471079fe1268-1.cs(151,138):

error CS0103: The name ‘pipeLocations’ does not exist in the current context

True, Spark too throws the error + code line in the face in some situations, but I didn’t figured out which ones.

3. Spark was built with MS MVC in mind thus its integration with Monorail is not entirely functional.

For example, ${Form.DisableValidation()} does not work.

4. Another annoying thing is that I have to declare the <viewdata Cities=”List<Storingen.Model.Cities>/> although I have already added the Cities in the PropertyBag in the controller.

The only advantage with Spark is that I can use C# code directly in views while in NV I had to build some helpers.

In Spark though, I have to declare the variables that I need in the view: <var Format=new FormatHelper()/>.

In the end, I have to admit that switching from NV to Spark was quite a shock for me…

P.S. for the next projects I’m heading to AspView, then for Brail… or the other way around..

Remember password for Outlook Web Access

When we’re working outside the office, we’re using the web interface to access the company’s email.

Because of some "security" reasons, the "autocomplete" property of the password field is set to "off" so browsers don’t offer you to remember the password.

When I login several times a day to check the email, entering the password each time becomes very annoying.




So… using Firebug you can set this property to "on", login and the browser will ask you whether to remember the user name and password.


Unfortunately this works only in Firefox. Both Chrome and IE 8 ignore this change, so you can’t use it.

But.. are there browsers other than Firefox?

SecureQueryStrings mania

I have inherited a web project, from a former coleague, that “senior” developer.

He’s a big fan of secured query strings, because he says, “Session is crap. It can be hijacked and your server put to its knees”.

This project has a wizard through which the user must go, about 7 pages. All communication between these pages is done with secure query strings.

Like this:

/// <summary>
/// Gets the project id.
/// </summary>
/// <value>The project id.</value>
private int projectId
        if ( this.PageParams != null && this.PageParams["projectId"] != null )
            return Convert.ToInt32( this.PageParams["projectId"] );
            throw new NullReferenceException( "this.PageParams[projectId]" );
/// <summary>
/// Gets the topic id.
/// </summary>
/// <value>The topic id.</value>
private int topicId
        if ( this.PageParams != null && this.PageParams["topicId"] != null )
            return Convert.ToInt32( this.PageParams["topicId"] );
            throw new NullReferenceException( "this.PageParams[topicId]" );

Each page has between 7 and 11 such properties, simply pasted from one page to the other.

Imagine a change of the business entities or a change in the workflow of the wizard. (I think “Find and Replace” is a very used feature of this guy :D)

Oh, and the comments, are generated automatically, using a dreaded tool – I shall not utter its name. Even though they don’t tell anything useful, they will not make the help file red.

This is what I consider a really bad example of how to build an application.

The right web.config for the right server

We have to manage 3 pretty large projects for a customer. The customer wants to test first, then say “ok, deploy it to production”.

There are about 16 settings per project, which are different for each of the 3 environments. Yes, I forgot to add that we have also the development area, where we publish bleeding edge features.

This scenario brings a problem, how to have the right config settings for the right server, without headaches.

The build is done automagically, through CruiseControl.NET, after each developer commits its part. Now back to web.config.

In trunk we have the good-for-dev version, which is the same for all developers.

Then we have an xml, which contains the good values for each server, then we have the keys and the new values that must be added to the file, overwriting the default ones:

<project name="Delta" configuration="PR" xmlns="http://www.delta.com/map.config.xsd" >
	<!-- RequestsConnectionString -->
	<key xpath="/configuration/appSettings/add[@key='RequestsConnectionString']/@value"
		   newValue="application name=huis-req;server=pr-server;database=Live_Delta;uid=****;pwd=****;Connect Timeout=100" />
	<key xpath="/configuration/system.web/compilation/@debug"
		   newValue="false" />

Then, a nant target loads the xml and the web.config and and replaces the values:

<!-- replaces certain fields in web.config with production values -->
<target name="prepare.web.config" description="replace certain fields with production values in web.config" >
	<xml-foreach file="${map.file}" xpath="/project/key" >
			<get xpath="@xpath" property="xpath" />
			<get xpath="@newValue" property="newValue" />
			<xmlpoke file="${web.config.file}" xpath="${xpath}" value="${newValue}" verbose="false" />

This target is called within the main target that wraps the whole project build task:

<!-- prepare Delta web.config in deployment directory -->
<target name="prepare.Delta.config">
	<property name="map.file" value="Delta.${db.type}.config.xml" />
	<property name="web.config.file" value="${kit.dir}\Delta\Web.config" />
	<call target="prepare.web.config" />
<!-- build Delta -->
<target name="Delta" >
	<call target="update.dependencies" cascade="false"/>
	<call target="startup" cascade="false"/>
	<call target="ms.build" />
	<call target="make.Delta.kit" />
	<call target="prepare.Delta.config"/>
	<call target="zip.Delta" />
	<echo message="Build finished." />
So, within seconds from clicking the "Force Build" or from last commit in svn, we have a package ready to be deployed to either DEV, TEST or PR environments ;).


Connection timeout because of FasterFox

So, I have installed FasterFox, hoping for a faster FireFox and I configured the add-on. Is not very clear from the text near the option "Disable IPv6 DNS lookups" whether this should be disabled or not.

So I checked the option.

This however led to localhost IIS being unavailable: "The connection has timed out".

Also, if the you have IPv6 (installed by default in Vista and Windows 7) you must have the following line in hosts file, otherwise you won’t be able to access your localhost.

::1             localhost    # IPv6 version of