Partilhar via


CodeBehind Vs Src

Visual Studio.NET implements CodeBehind by precompiling the base class, then uses the Inherits keyword to refer to that class.

<%@ Page language="C#" Inherits="MyBlog.HelloWorld" Codebehind="HelloWorld.aspx.cs" %>

According to the .NET documentation, the Src attribute of the Page directive specifies the source file name of the code-behind class to dynamically compile when the page is requested (during runtime).

<%@ Page Language="C#" Inherits="MyBlog.HelloWorld" src="HelloWorld.cs" mce_src="HelloWorld.cs" trace="true" %>
<html>
<body>
<asp:Label id="lblMessage" runat="server" />
</body>
</html>

Simply saying Codebehind is generated automatically by Visual Studio .Net whereas the Src is used to refer the code behind(Preferably in case of application development without VS .Net).

Comments