Using CodeFile

Using CodeFile

Codebehind Declarations

  • Used in Web Application projects in Visual Studio, which is the required type of project to work with Sitecore 
  • Requires developers to build after each code edit to user controls

CodeFile Declarations

  • Normally implemented with website style projects where all files in the hierarchy are included in the project
  • Can be used with individual user controls even though Sitecore only supports Web Application projects
  • Builds occur automatically when changed user controls are loaded
  • Does not update designer file when controls are added to .ascx file from Visual Studio toolbox
  • Can use context menu in Solution Explorer to convert .ascx to Web Application Project 
  • This will update designer file but will reset CodeFile declaration back to Codebehind


  • Consider using Codebehind when you will be adding more controls to your .ascx file
  • Consider using CodeFile when you are done adding controls and just writing code