Monday, January 18, 2010

lblBuildInfo.Text = "Build " + BuildDate.ToShortDateString;

Operator '+' cannot be applied to operands of type 'string' and 'method group'

This is happening with some code I pushed through a converter to c#. Being lazy sometimes has it's benefits, but not here.

Hmm, syntactically these looks correct, but there's a little more to it. is nonchalant about functions ending in a paren pair (). c# is not. The converter did not even bother telling me this was a problem, and took my code.

lblBuildInfo.Text = "Build " + BuildDate.ToShortDateString();

Is correct.

Thursday, January 14, 2010

Double postback on forms

I have a recent situation where a page_load event is firing multiple times in (2.0). Sometimes it's twice, sometimes many times.

There are several things that cause this, I've been bitten by two of them.

1) Having two events hooked to the page_load via the Handles clause. Note the Me.load. This appears to be placed sometimes by the IDE.

Private Sub Page_Load(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load <--eek!

2) This one really threw me. Sometimes an Image control with no URL will cause this. Also, links with blank URLS can also cause this. When diagnosing, substitute in as needed.

New Blog

I thought it was about time to create a blog for my site and business, In daily development life I stumble across a lot of interesting and useless information that may benefit someone. This is my legacy.