re:
I believe Pawel is trying to split his code-behind partial class
across multiple files.
Maybe we're geting bogged down in semantics here but,
isn't that what the images I sent show ?
person.birth.cs and person.name.cs are
getting compiled into a single *person class*.
Of course, you can't have 2 codebehind pages for the *same* page,
but the objective isn't to split the codebehind like that, so that UI
and codebehind get mixed.
That will not be possible and is not an objective.
The objective is to "containerize" different parts of the same class
into different files, so that -for example- different parts of the same
class can be worked on by different developers without risk of
overwriting code.
See
http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx
From that article :
C# 1.1 requires you to put all the code for a class in a single file.
C# 2.0 allows you to split the definition and implementation
of a class or a struct across multiple files.
You can put one part of a class in one file and another part of the class
in a different file, noting the split by using the new partial keyword.
In fact, you can have as many parts as you like in any given class. Partial type support
is available for classes, structures, and interfaces, but you cannot have a partial enum
definition.
Partial types are a very handy feature. Sometimes it is necessary to modify
a machine-generated file, such as a Web service client-side wrapper class.
However, changes made to the file will be lost if you regenerate the wrapper class.
Using a partial class, you can factor those changes into a separate file.
ASP.NET 2.0 uses partial classes for the code-beside class
(the evolution of codebehind), storing the machine-generated part of the page separately.
C# 2.0 supports partial types as follows: when the compiler builds the assembly,
it combines from the various files the parts of a type and compiles them into a
single type in Microsoft intermediate language (MSIL).
The generated MSIL has no recollection which part came from which file.
Just like in C# 1.1 the MSIL has no record of which file was used to define which type.
Also worth noting is that partial types cannot span assemblies, and that a type can refuse
to have other parts by omitting the partial qualifier from its definition.
Because all the compiler is doing is accumulating parts, a single file can contain
multiple parts, even of the same type, although the usefulness of that is questionable.
In C#, developers often name a file after the class it contains
and avoid putting multiple classes in the same file.
When using partial types, I recommend indicating in the file name that it contains
parts of a type such as MyClassP1.cs, MyClassP2.cs, or employing some
other consistent way of externally indicating the content of the source file.
It's the *class* which can be, and gets, split into multiple files,
not the page's codebehind.
Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ :
http://asp.net.do/faq/
==========================