Partial Types with Code Behind Pages in ASP.NET 2.0?

G

Guest

I just read on Slash Dot about partial types.

Now, is it possible to have a code behind split over two pages but still
referencing the same .aspx file???

If so, that would be really nice as every now and then there is some code
behind code that just gets to be a lot for a single .aspx page


Untitled.aspx
Untitled.aspx.1.cs <- part 1 that works with Untitled.aspx
Untitled.aspx.2.cs <- part 2 that works with Untitled.aspx



So when I hit the Untitled.aspx with my browser, it automatically JITs both
the split code behind pages together....this seems like something very
doable in ASP.NET 2.0.....
 
J

Joshua Flanagan

Yes, that is what partial types means. You will be able to split up the
definition of your class "Untitled" between multiple .cs files.

That said, there is no guarantee that the VS IDE will support multiple
code-behind files for ASPX pages. Just because the language and framework
support it, doesn't mean the IDE will (think in-line server-sie code,
multi-file assemblies, etc).
 
N

news.microsoft.com

Watch the nightmare of missmash of wizard code being, not that its bad
enough already with it stomping all over #regions, now its gona spam .cs
files.
 
G

Guest

So, are you saying that the .aspx file will have a place for you to tell it
to
have multiple src= files?

right now all you can put is src="Untititled.aspx.cs"

Where would I put the other file name ?
 
G

Guest

Ok, thanks.

However, how does the the MyFile.aspx.cs file know where the other part of
the partial file is in the first place.

I can see from the codebesides attrtibute "compileswith" shows the first
partial file, but what about the second and third, etc. partial files that
go with the first file?
 
T

Thomas Tomiczek \(MVP\)

It does not have to know

The compiler knows.

I would say that the compiler first creates a list of all types (which it
needs anyway), and at this point it can link them together.

Dont forget: partial types are a COMPILER feature. They dont exist in the
assembly.

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top