views:

412

answers:

2

What is the use of the CodeFile attribute in an ASP.NET page ?

A: 

Fritz Onion probably has one of the best explanations of the CodeFile attribute I've seen:

More details on code behind v2 (PluralSight)

Kev
+1  A: 

In classic asp we used to write html source and C# or VB code in same file

But in .net 2.0 , we write html code of page in one file and C# or VB code in different file and reference this file in html source of the page using code behind attribute so that compiler know where to find the code for that page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

here CodeFile="Default.aspx.cs" tells to look for C# code in Default.aspx.cs file

.

ASP.NET Articles

thanks for giving wonderful answer
KuldipMCA