gpt4 book ai didi

asp.net - 页面指​​令继承属性

转载 作者:行者123 更新时间:2023-12-02 10:06:59 27 4
gpt4 key购买 nike

我只是想知道是否有人知道 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com