August 8, 2002 - Introducing CodeBehind
August 8, 2002 Introducing CodeBehind Tips: August 2002
Yehuda Shiran, Ph.D.
|
.html
files mix HTML and JavaScript code. The HTML portion serves as the presentation layer of the Web site. This layer includes GUI widgets such as forms, button, text boxes, menus, and banners. The JavaScript portion is responsible for the business logic. It usually includes event handlers and functions to handle the user's requests. The HTML portion is static, and is independent of the user's actions. The JavaScript portion, on the other hand, is dynamic and is dependent on the user's actions.
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:TextBox
and ASP:Label
. The dynamic part is JScript code, residing in a separate .js
file.
The integration of the .aspx
and the .js
files is a bit complex. The .js
file is not just included in the .aspx
file. The .NET framework compiles it first, and then lets the .aspx
file call methods from the derived binary dll
. This process is hidden from you. The browser tries to load the binary dll
file, but if the source has changed after the dll
creation date, the browser will automatically recompile the source file.
To learn more about JScript .NET and ASP.NET, go to Column 115, JScript .NET, Part IX: Code Behind.