What is the use of the CodeFile
attribute in an ASP.NET page ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
CodeFile attribute is used for deploying a single page without deploying the whole application :-
Here are the instructions to deploy a single page to a web application. The following example is using the page /Forms/CreateUser.aspx
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
To:
public partial class CreateUser1 : System.Web.UI.Page
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"
To:
Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="CreateUser.aspx.cs" Inherits="Forms.CreateUser1"