Thursday, October 30, 2008

Internet Explorer CSS Quirk (border-spacing)

Consider the following CSS class:

.test
{
    border-spacing: 0px; /*Only works in Firefox */
    border-collapse: collapse;    /*Works in Firefox and IE */
}

With the border spacing CSS style attribute set to zero pixels, Firefox and IE render differently:

Internet Explorer:

ie

Firefox:

firefox


Moral: Use "border-collapse: collapse;" when you want no border spacing in your tables.

Tuesday, October 28, 2008

Why Is My Property Not Being Serialized To XML?

Had a very frustrating problem the other day when trying to use a service proxy that I had generated via svcutil.exe.  The symptom was that some of the properties that I was setting on my proxy objects were not being serialized to the message that was being sent via my WCF binding. 

The short answer is that some of the properties in my objects had some associated properties that needed set.  Take these two properties for example:

1485 

1486     /// <remarks/>

1487     [System.Xml.Serialization.XmlAttributeAttribute()]

1488     public bool definitive

1489     {

1490         get

1491         {

1492             return this.definitiveField;

1493         }

1494         set

1495         {

1496             this.definitiveField = value;

1497         }

1498     }

1499 

1500     /// <remarks/>

1501     [System.Xml.Serialization.XmlIgnoreAttribute()]

1502     public bool definitiveSpecified

1503     {

1504         get

1505         {

1506             return this.definitiveFieldSpecified;

1507         }

1508         set

1509         {

1510             this.definitiveFieldSpecified = value;

1511         }

1512     }


As you can see, when svcutil created the property for the "definitiveField" property in the XML schema, it also created a "definitiveSpecified" field.  If you leave the *Specified field left to it's default value (false), the property will not serialize and you'll be left scratching your head.

Why?

It turns out that if the XML schema defines a property as optional using "minOccurs=0" (or you could think of it as 'nullable'), then the .Net XMLSerializer will not serialize the default value for the property.  It makes sense - you wouldn't want the framework to assume that you want the default for a particular value... but nevertheless - this is a major gotcha.

Thursday, October 23, 2008

Central Ohio .Net Developers Group: jQuery

I gave a very short 15 minute "Lightning Talk" on jQuery at the Central Ohio .Net Developers Group. Here is the demo project and slide deck:

jQuery Presentation (SkyDrive)