What is the difference between CodeFile="file.ascx.cs" and CodeBehind="file.ascx.cs" in the declaration of a ASP.NET user control?
Is one newer or recommended? Or do they have specific usage?
What is the difference between CodeFile="file.ascx.cs" and CodeBehind="file.ascx.cs" in the declaration of a ASP.NET user control?
Is one newer or recommended? Or do they have specific usage?
CodeFile is newer, it's introduced with ASP.NET 2.0, while CodeBehind is there from the start.
A longer explanation on what each of the names does can be found at this good blog post:
http://blog.mjjames.co.uk/2008/02/so-what-is-it-code-behind-or-code-file.html
It all comes down on what gets compiled, when and where.
More resources at: http://www.pluralsight.com/community/blogs/fritz/archive/2005/01/18/5111.aspx
CodeBehind = Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text ... for example when delivering to a customer who you not have obligation to provide code.
CodeFile = You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsfot.NET[.NET version]\Temporary ASP.NET Files.