ASP.Net 2.0 - refering to the web page class

Discussion in 'ASP .Net' started by =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 9, 2006.

  1. 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
     
    =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 9, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?TmljayBaZHVuaWM=?=

    Bruce Barker Guest

    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)

    "Nick Zdunic" <> wrote in message
    news:...
    > 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
    >
     
    Bruce Barker, Feb 10, 2006
    #2
    1. Advertising

  3. 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

    "Bruce Barker" wrote:

    > 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)
    >
    > "Nick Zdunic" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
    >
     
    =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 10, 2006
    #3
  4. =?Utf-8?B?TmljayBaZHVuaWM=?=

    Guest

    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.
     
    , Feb 10, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmljayBaZHVuaWM=?=

    Refering to web page class from another class

    =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 8, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    448
    Karl Seguin [MVP]
    Feb 8, 2006
  2. =?Utf-8?B?Um9zcyBIb2xkZXI=?=

    Refering to Object Members in A Collection in an ASP.NET BoundColu

    =?Utf-8?B?Um9zcyBIb2xkZXI=?=, Mar 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    488
    =?Utf-8?B?Um9zcyBIb2xkZXI=?=
    Mar 10, 2006
  3. Sameer
    Replies:
    2
    Views:
    1,212
    Roedy Green
    Aug 28, 2005
  4. JJ
    Replies:
    4
    Views:
    481
  5. TRalia

    Refering to a control on a page shown in a frameset

    TRalia, Jan 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    152
    TRalia
    Jan 21, 2004
Loading...

Share This Page