Article ID: 303247 - Last Review: February 23, 2007 - Revision: 3.4 INFO: ASP.NET Code-Behind Model OverviewThis article was previously published under Q303247
This article refers to the following Microsoft .NET Framework Class
Library namespace:
On This PageSUMMARY This article provides a brief overview of the code-behind
model, which is introduced in ASP.NET. MORE INFORMATION ASP.NET supports two methods to author pages:
In-Line CodeIn-line code is code that is embedded directly within the ASP.NET page. The following code represents a sample ASP.NET page that includes in-line code:Myinlinecode.aspx Code-BehindCode-behind refers to code for your ASP.NET page that is contained within a separate class file. This allows a clean separation of your HTML from your presentation logic. The following sample illustrates an ASP.NET code-behind page:MyCodebehind.aspx csc.exe /out:mycodebehind.dll /t:library mycodebehind.cs When you use the following code, the code-behind page
inherits from the Page class. The Page class resides in the System.Web.UI namespace: In the preceding sample, the code-behind page is compiled before ASP.NET runs. Alternatively, you can reference the code-behind class by using an SRC tag as follows: Code-Behind Support in Visual Studio .NETWhen you use Microsoft Visual Studio .NET to create ASP.NET Web Forms, code-behind pages are the default method. In addition, Visual Studio .NET automatically performs precompilation for you when you build your solution. Note that code-behind pages that are created in Visual Studio .NET include a special page attribute, Codebehind, which Visual Studio .NET uses.REFERENCESFor
additional information%1, click the article number%2 below to view the
article%2 in the Microsoft Knowledge Base: 313105
(http://support.microsoft.com/kb/313105/EN-US/
)
BUG: Cannot Compile Code-Behind Files That Use Src Attribute on a UNC Share
| Article Translations
|
Back to the top
