![]() |
|
|
Published: Thursday, October 05, 2000 By Mani Raja
Even though ASP.NET is the next version of ASP, it is more than just a next version. ASP.NET is completely re-designed from the ground up and it provides a neat object oriented programming model. An ASP.NET page is an object derived from the .NET Page class. We all know that ASP.NET provides several new features and one of the important features is the separation of code and content. In today's ASP application, we have a mix of HTML and Scripts making the code difficult to read, debug and maintain. ASP.NET relieves us from this problem by promoting the separation of code and content. That is, the user interface and the user interface programming logic need not necessarily be written in a single page. There are two ways in which you can separate the code and content:
2.) By developing the frequently used page logic in to separate files called Pagelets (also known as page controls) and by using them several times in your ASP.NET pages. As the title of the article indicates, I will explain the first mechanism that is used to neatly encapsulate the UI functionality in to a separate pre-compiled module. You will typically follow the steps below to develop an ASP.NET page that uses code-behind pages:
2.) Create the code-behind file using the .NET runtime classes that mimic the entire ASP.NET page with the member variables that correspond to the HTML and/or Web controls used in the ASP.NET page. The extension of code behind files will vary depending on the language you use. Typical extensions will be .cs for C#, .vb for VB7 and .js for JScript .NET Now, we know that there are two separate files: one for the UI and the other for the UI logic. But, how do we relate these two files so that the ASP.NET page compiler will locate the code-behind file for the ASP.NET page. The glue between these two files is provided through the Page Directives, which are used to specify optional settings at the page level.
Creating the "Content"
The first line of the ASP.NET page is the page directive that specifies the
name of the code behind file and the actual class name inside that file. In
our example, the file name is
The namespace that I used for this code behind page is In Part 2 we'll examine creating the complementing code for our .aspx page!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||