Referencing Page classes (2.0)

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
So by luck I found that if you have a user control you want to reference called 'MyUserControl' you can create and instance of it through ASP.MyUserControl_ascx for pages that need it.

However I haven't figured out how to get the page - where they've hidden that class. If you're in the page your referencing, there it is, but outside of it you can't. You also can't put your code behind in a namespace because of the whole partial class thing...you'll get a compile error.

Does anyone know how you could create an instance of the code behind of page file? Or how to change the namespace - or even have one for a code behind - they don't seem to have one right now.

I have something that in the future I'm going to need this functionallity - I have a set of classes that basically have an association (in UML) between the two and I'd hate to redesign a functional set of pages because of this now 'missing' ability.
 
That's cool, but it just raises more questions. If they're going to be able to make an addition to do these things, why can't I manually do them now? I'm honestly disappointed at MS for taking that away. I'm sure it has to do with these partial classes and how they're used deep down to make the MSIL - but if a page should have a code behind, and that code behind is a class, then I should be able to make that class public and instantiate it anywhere in my project. On those same lines, I should be able to declare controls on my page publicaly accessible - not that I approve of that kind of design - but I should at least have the ability to.
 
Back
Top