Code-Behind Vs Inline Code in Asp.Net

What is Code Behind?

Code Behind refers to code for ASP.NET page which is contained within a separate class file. It is composed in a different class record that can have the extension of .aspx.cs or .aspx.vb relying upon the language used. It allows a clean separation of HTML from the presentation logic. In the code-behind file, you create a class (which can be any class derived from the Page class) that serves as the base class for the web page you create in the .aspx file. This relationship between your class and the web page is established by a Page directive at the top of the .aspx file:
< %@ Page inherits="NewPage" % >
The inherits attribute identifies the class created in the code-behind file from which this .aspx file will derive. One major point of Code Behind is that the code for all the Web pages is compiled into a DLL file that allows the web pages to be hosted free from any Inline Server Code.

What is Inline Code?

Inline Code is embedded directly within the ASP.NET page that has an extension of .aspx . It permits the code to be composed along with the HTML source code using a < Script > tag. When the page is deployed, the source code is deployed along with the Web Forms page , because it is physically in the .aspx file. However, you do not see the code, only the results are rendered when the page runs.