【问题标题】:What is the use of the `CodeFile` attribute in an ASP.NET pageASP.NET 页面中“CodeFile”属性的用途是什么
【发布时间】:2009-06-29 13:58:34
【问题描述】:

CodeFile 属性在 ASP.NET 页面中的用途是什么?

【问题讨论】:

    标签: asp.net webforms asp.net-2.0


    【解决方案1】:

    CodeFile 属性用于部署单个页面而不部署整个应用程序:-

    以下是将单个页面部署到 Web 应用程序的说明。以下示例使用页面 /Forms/CreateUser.aspx

    在 .cs 文件中,将类的名称更改为不存在的名称。例如,更改以下内容:

    public partial class CreateUser : System.Web.UI.Page
    

    收件人:

    public partial class CreateUser1 : System.Web.UI.Page
    

    在aspx、ascx、master等中将Codebehind改为CodeFile,并将Inherits属性中指定的类名改为.cs文件中的同名。例如更改以下内容:

     Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeBehind="CreateUser.aspx.cs" Inherits="Forms.CreateUser"
    

    收件人:

    Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="CreateUser.aspx.cs" Inherits="Forms.CreateUser1"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-25
      • 2019-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-01
      • 2020-11-01
      相关资源
      最近更新 更多