我只是想知道是否有人知道 Inherits 属性在此 Page 指令中的含义以及它为什么使用 ._Default。
最佳答案
根据 MSDN:-
Defines a code-behind class for the page to inherit. This can be any class derived from the Page class. This attribute is used with the CodeFile attribute, which contains the path to the source file for the code-behind class.
假设您有一个页面 Default.aspx
具有以下页面指令:-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="MyNamespace.Default" %>
CodeBehind
属性告诉您包含与页面关联的类的编译文件的名称。
假设 Default.aspx.cs 如下所示:-
namespace MyNamespace
{
public partial class Default: System.Web.UI.Page
{
//
}
public class Employee
{
//
}
}
自从在Default.aspx.cs
文件中可以有多个类(默认和员工),在本例中为 Inherits
属性指定继承哪个类。
关于asp.net - 页面指令继承属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33295718/