A basic code behind tutorial can be found at...
http://www.4guysfromrolla.com/webtech/100500-1.shtml
its not really much different than not doing it. The only real differences being
a) that you need to put a directive at the top of the aspx page, telling it where its code is
b) in the code file you need to declare all the controls that you use
c) you cannot directly access html tags simply by giving them an id and a runat="server". You have to create custom controls instead.
d) you precompile the code into a dll. Visual Studio makes this last step pretty easy. Not sure how you'd go about it from the command line, since it puts all the pages into a single dll with the name of your web project and I only have experience of compiling from a single source on the command line.
If I'm wrong about any of this I'd like to know...