ASP pages can be written in one of 2 ways – inline or code-behind.
Code-behind pages separate the user interface from the business logic, making it a better choice in most cases.
Code-behind files allow a developer to separate the UI display from the UI processing.
The only code that should exist in the ASPX file itself is code (typically script) that specifically services the display.
It is generally easier to reuse code in a code-behind file than in a single file with inline code.
Code-behind development provides separation of the design and development functions, allowing designers to work on the ASPX file and coders to do the code-behind development.
Advantages of code-behind development include:
- compile-time warnings
- type safety
- better debugging support since Visual Studio was designed for code-behind development./li>
Read more about the code-behind model.