比如Default.aspx页面,.cs可能生成一个叫_Default的类或者叫Default的类
而.aspx会生成一个叫aspnet_Default的类,这个类继承自_Default类/Default类
因此,如果你在.aspx写了与.cs中有相同签名的方法,.aspx中的方法是最后会执行的,.cs的就被无视了
partial是用在类,接口的拆分定义上的,并不包括html
aspx是页面文件,cs是代码文件,不一样的,是分离的.
partial是对cs中代码的拆分,和aspx没关系的
好像是继承的关系,呵呵
aspx页面是继承cs代码的。他们是继承关系。aspx页面中这个地方可以看出来Inherits="类名"。
私有变量是不能访问的,应该使用protected或者public类型才可以。
它们的执行顺序就是先执行cs代码,后执行aspx代码页面。
.aspx中定义的类是.aspx.cs中定义的类的子类
最直接的体现就是可以在.aspx中访问对应的.aspx.cs中定义的protected方法,而不能访问private方法。
aspx是页面文件,cs是代码文件.
汇总下楼上各位的回答: *_*
1.partial意指C#类,接口的折分,并不包含HTML文件.
2.Inherit指aspx的页面的C#代码和code behind所指CS文件的代码的继承关系.所以说aspx文件关联的CS文件的私有成员是不能访问的。如需要访问只能将来code behind文件的方法||属性的声明更改为protect,public.
3.partial 用在aspx的code behind文件中是来辅助原有的code behind方式这种方式叫做code beside.可以在在1.0中每往aspx上拖一个控件,那么在它的code behide 的文件就会有一个声明,而现在这个声明这被移到了别个文件中它的类名和code behide文件一样,且也有partial声明叫xxx.aspx.desinger.cs.
如果你想研究的更深一点,可以参考它的内部机制:
关于编译和临时文件的:
The page handler factory is responsible for either finding the assembly that contains the page class or
dynamically creating an ad hoc assembly. The source code for the class is created by parsing the
source code of the requested .aspx resource, and it's temporarily saved in the following ASP.NET
temporary folder:
%SystemRoot%\Microsoft.NET\Framework\[version]\Temporary ASP.NET Files
In ASP.NET 1.x, the page class inherits from the code-behind class you created with Visual Studio. In
ASP.NET 2.0, the page class is an enhanced and completed version of the partial class in the Visual
Studio .NET code file. In particular, the partial class in the project is completed with a second partial
class dynamically arranged by the ASP.NET HTTP runtime.
关于部分类的职责:
Partial classes are a new feature of .NET Framework 2.0 compilers that allow you to break up the
definition of a class into multiple, partial files. Each constituent class appears to be a perfectly valid and
legal class definition, except that each is missing some of the logic and features expected of the overall
class. The compiler will then take care of merging partial classes into a regular, nonpartial class that
can be compiled to an assembly.
Partial classes are a source-level and assembly-limited way to extend the behavior of a class. In this
regard, partial classes are not an object-oriented feature. Partial classes save time during the
development cycle. They enable multiple teams to work on the same component at the same time, and
they provide an elegant way to add functionality to a class incrementally by adding a new class instead
of touching existing file classes.
Partial classes are used in ASP.NET 2.0 to overcome the brittleness of tool-generated code such as that
found in ASP.NET 1.x projects. If you ever developed applications with Visual Studio .NET 2003, you
should be familiar with those weird, auto-generated, semihidden regions of code that Visual
Studio .NET 2003 inserts to support page designers. That code is required to extend code-behind
classes with members that link to server controls dropped onto the underlying Web Form. Keeping the
code-behind class in sync with the evolution of the Web Form might not be easy if you tend to edit the
aspx source directly from the HTML editor. Partial classes remove the issue at the root: no more toolgenerated
code during the development phase. At compile time, the partial code-behind class is
completed with member definitions, and this code is completely hidden from developers.
ASP.NET Temporary Files
Generating an assembly for a particular .aspx resource is a two-step process. First, a class file is
created that fully represents the markup of the .aspx file. Second, the dynamically generated class is
compiled into an assembly and cached in the Temporary ASP.NET Files folder. There will be a distinct
folder for each installed version of ASP.NET
呵呵,回答这么多了,简单的说,就是code behind
呵呵,都差不多了