I’ve done it both ways, and to be honest other than the ability to give the code and webform to two different people (which doesn’t happen where I work), I see very little advantage of one method over the other. I can understand how it is nice to have your code in one file, and markup in the other, but I can also understand the ease of having both in a single file.
I don’t see how using code-behind enforces any sort of ‘good’ programming, because you can still write crappy code in code-behind, and I’ve seen some really clean stuff with in-line.
So my real questions, what method are you using? and is there anything you can do programatically with code-behind that simply cannot be done with in-line code? or does it all really come down to the simple matter of ‘personal preference’. Microsoft seems to not take a real stand on one way or the other and performance wise, it seems a wash.
Opinions?
Definitely. With a large pinch of ‘level of tolerance for noise’.
Jeff recently posted on this, and I tend to agree. If the source is mostly markup then inline code works well, however if the source is mostly code then code behind (and as Jeff notes VB’s XML support could really help here).
When you are setting a few values you may find you make a different choice to cases where the structure of the HTML is lost in the code (e.g. when the created HTML is very much determined on the fly).
Where is the right balance?… that’s the preference bit.