Jump to content

Code-behind

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sundippankaj (talk | contribs) at 07:29, 4 December 2006 (Code-Behind). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Code-Behind

In ASP.Net the logic and presentation has been separated. The presentation is the .aspx or .ascx files. The code-behind contains the actual programmatic logic.

In the traditional ASP style of development, the coding logic has to be nessecarily embedded into the HTML. This made writting code and maintaining it extremely difficult. All the code is written in a single .asp file.

In ASP.Net two files are created in place of the single .asp file.

.aspx - This file contains the HTML, the Server-side controls and the Javascript. Thus it is pure data representation.

.aspx.cs or .aspx.vb - This contains the actual logic for data control. This make debuging and maintainance easier. The file is suffixed by a .cs (C#) or .vb (Visual Basic) depending on the language used to program.

Hence a Code-Behind is exactly what it is, a code behind the actual HTML.