Refering to web page class from another class

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

  1. In 1.1 it was possible to refer to a web page class from another class

    I've just started in v2.0 and found that this code sn't working

    The web page class:

    Partial Class _Default

    Inherits System.Web.UI.Page

    End Class

    The class that want to refer to this:

    Public Class Class1

    Private _def As _Default

    End Class

    The _def variable wont compile as _Default is not defined.

    Is there a directive I'm missing?
     
    =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 8, 2006
    #1
    1. Advertising

  2. This is made more difficult in 2.0 :(

    The only way I know around it at this point is to place an interface for
    your default class in app_code and reference the interface rather then the
    class.

    public interface IDefault
    public property Name as string
    end interface

    partial class _Default
    inherits Page
    Implements IDefault

    public property name as string
    get ..
    set..
    end property
    end class

    public Class Class1
    private _def as IDefault
    ....
    end class.

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "Nick Zdunic" <> wrote in message
    news:...
    > In 1.1 it was possible to refer to a web page class from another class
    >
    > I've just started in v2.0 and found that this code sn't working
    >
    > The web page class:
    >
    > Partial Class _Default
    >
    > Inherits System.Web.UI.Page
    >
    > End Class
    >
    > The class that want to refer to this:
    >
    > Public Class Class1
    >
    > Private _def As _Default
    >
    > End Class
    >
    > The _def variable wont compile as _Default is not defined.
    >
    > Is there a directive I'm missing?
    >
     
    Karl Seguin [MVP], Feb 8, 2006
    #2
    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=?=

    ASP.Net 2.0 - refering to the web page class

    =?Utf-8?B?TmljayBaZHVuaWM=?=, Feb 9, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,451
  2. Sameer
    Replies:
    2
    Views:
    1,209
    Roedy Green
    Aug 28, 2005
  3. JJ
    Replies:
    4
    Views:
    480
  4. 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
  5. Replies:
    11
    Views:
    277
    C├ędric Finance
    Nov 8, 2007
Loading...

Share This Page