5

I read through the previous post: CodeFile vs CodeBehind, but I'm still confused on which I should use. It sounds like CodeFile is the newer option that should be used, yet VS2010 generates CodeBehind when creating a new Web Form.

Community
  • 1
  • 1
Donald Hughes
  • 6,627
  • 8
  • 35
  • 46

1 Answers1

2

It depends on your template, check out web site vs. web application. I tend to prefer web application for several reasons, but that is up to you. If you see code-behind, you probably have selected that template.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Okay, that's what I did. Just wanted to verify that was the reason. Does the code-behind require pre-compilation, or will new code get compiled on the fly? – Donald Hughes Apr 06 '10 at 15:49
  • Websites can be precompiled (or 'published'), otherwise pages get compiled on the fly. I also prefer web application projects however and would recommend them for any reasonable sized project. – richeym Apr 06 '10 at 17:18
  • Code-behind itself doesn't precompile but the code-behind is compiled into a single DLL, but web sites are dynamically compiled at runtime as mentioned by @richeym. Precompilation can be done for both project types, as it also compiles the markup too, so there isn't the initial page compilation hit. – Brian Mains Apr 06 '10 at 18:51