Code Separation and Using Code-Behind

As we’ve discussed before, ASP.NET has provided a really cool way to keep code separate by changing the paradigm from an inline, interpreted language to an object/event-oriented paradigm. But ASP.NET doesn’t stop there. It provides another level of separation of code and content if you want to use it. It’s called the code-behind technique.

This subject was mentioned briefly in Chapter 1 and also appeared in a little example, but here the code-behind technique is dissected so you can fully understand what’s happening.

The following is an example of a typical ASP.NET page that doesn’t utilize any code-behind techniques. It has an ASP:Label control that you’re familiar with, a few server controls, and a button ...

Get ASP.NET for Web Designers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.