ASP.Net 2.0 - refering to the web page class

G

Guest

Just loaded up ASP.Net 2.0 and found that I can't refer to a specific web
page class from another class.

For example:

Partial Public Class _Default
Inherits System.Web.UI.Page

End Class

In another class defined in tha project, I get a Not Defined error

Public Class Class2

Private _def As _Default 'this line generates the error

End Class

I'd like to be able to do this so I can implement the MVC pattern.

Must be something simple as I could not imagine that this would be a
restriction.

Regards,

Nick
 
B

Bruce Barker

you shouldn't need this for the MVC pattern, but to reference another page,
you need reference directive in the calling page.

-- bruce (sqlwork.com)
 
G

Guest

The implementation of MVC I use, taken from profession Design Patterns in
VB.Net, does need it.

Class2 is not a page it is normal class that needs to have a reference to
webpage class _Default
 
J

jhcorey

What we did was create a BasePage class in a sub-folder under App_Code
(you've probably realized that this is where you have to put the code
that's not part of a page).

For you it would look like this:
Public Class BasePage
Inherits System.Web.UI.Page

End Class

Then your _Default page would inherit from BasePage.
Include in BasePage all the functions you wanted to expose from
_Default.
 

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