ASP.NET页中`CodeFile`属性的用途是什么 [英] What is the use of the `CodeFile` attribute in an ASP.NET page

查看:235
本文介绍了ASP.NET页中`CodeFile`属性的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the use of the CodeFile attribute in an ASP.NET page ?

推荐答案

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

CodeFile attribute is used for deploying a single page without deploying the whole application :-

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

Here are the instructions to deploy a single page to a web application. The following example is using the page /Forms/CreateUser.aspx

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

In the .cs file change the name of the class to one that doesn't exist. For example, change the following:

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

收件人:

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

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

In the aspx, ascx, master, etc. change the Codebehind to CodeFile and change the name of the class specified in the Inherits attribute to the same name as in the .cs file. For example change the following:

 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"

这篇关于ASP.NET页中`CodeFile`属性的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆