ClassName
is used for giving a name to the page, when we use inline code[ meaning all of the HTML and server-side code is included in the single page]. Therefore this attribute should be used when we have the server side code within the aspx page only using Script blocks, like:
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
welcomeLabel.Text = "Hi There";
}
</script>
This can be used for both Pages or user controls.
At run time, a single-file page is treated as a class that derives from the Page class. AND THIS CLASS SHOULD HAVE A NAME
Since there is no seperate C# code file [ Also known as Code Behind file ], there is no explicitly defined class. In order to give the page's class a name, the ClassName
attribute is being used.
Inherits Attribute::
If we place the server side code for the page in a .cs file, then only we should use Inherits
attribute.
When a web form is compiled, its page is parsed and a new class is generated and compiled. This new class derives from the class identified in the inherits
keyword.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LINQ2Entities.aspx.cs"
Inherits="LINQ2Entities" %>