JScript .NET, Part IX: Code Behind
The Benefits of Code Behind
The .NET environment provides an alternate paradigm for server-side Web sites. The Code Behind concept calls for a separation between the presentation layer and the business logic. The static part is ASP.NET code, residing in the
.aspx file. It includes ASP.NET controls such as
ASP:Label. The dynamic part is JScript code, residing in a separate
The integration of the
.aspx and the
.js files is a bit complex. The
.js file is not just included in the
.aspx file. You need to compile it first, and then let the
.aspx file call methods from the derived binary dll.
Separating the JScript code from the ASP.NET code has several benefits. From the software engineering point of view, the code is better organized: every file is either 100% ASP.NET or 100% JScript .NET. Another benefit is that distributed development is easier with Code Behind. Since there are two separate files, the Web site graphic designer can work on the ASP.NET code, while the JScript hacker can program the business logic behind the scenes.
The advantage of Code Behind to you is that the .NET framework compiles your Code Behind automatically, whenever the ASP.NET page is displayed; assuming the JScript has not already been compiled, or has been changed since the last compilation. In this column, we choose to show you what's going on behind the scenes, and will teach you how to compile the Code Behind explicitly. In this way, you will better know what the Developer's Studio is doing when building a project.
Next: How to write the Code Behind of Hello World