Accessing class from codebehind

Discussion in 'ASP .Net Web Services' started by Kristoffer Arfvidson, Dec 19, 2003.

  1. Hi!
    Don´t know If I ended up on the right server for this question, but Ive been looking for ever now for the answer, and please if somebody knows, please help me!

    My problem is the following:
    I have an aspx page, called: Page1.aspx
    on top of this page I have the following written line:
    <%@Page language="vb" AutoEventWireup="true" Debug="true" Trace="true" inherits="clsCodeBehindIndex" src="page1.aspx.vb" %>

    ok, Now, I have a codebehind page called: Page1.aspx.vb inside witch I have for example:
    imports system
    imports system.web
    imports system.web.ui
    imports system.web.ui.webcontrols
    imports system.web.ui.htmlcontrols
    'imports N.clsClientInfo





    public class clsCodeBehindPage
    Inherits System.web.ui.page
    public lbl as label

    sub Page_Load(sender as object,e as eventargs)
    lbl.Text = "page load in Code Behind"

    end sub
    end class


    ------------
    ok, now, I have a third file called: clientinfo.vb witch is on a different dir on the server eg. "../Global/clientinfo.vb"
    ok, This is a GLOBAL Class, witch will be accessed thruout the page and contains information about the current client. ok...

    So, now to my question, HOW??? on earth do I connect to this class thru my codebehind page? (page1.aspx.vb) ??
    I can access the page by using: <%@ Assembly src="../global/clientinfo.vb" %> (on the normal aspx page) BUT!
    I cant get access to the class in the codebehind page, ONLY on my normal aspx page...

    I try to access the class by typing (in the codebehind page):
    Dim ClientInfo as new clsClientInfo
    But I keep getting error messages...

    OBS!
    I cant use VS.NET since my homepage provider dosnt support dll´s, so, I need to make this work, somehow...

    Any suggestions?

    Please help me, I have been looking for a week now, and still havnt found any info about this... :(

    Here comes some example code for the clientinfo.vb class:
    Namespace N 'Declare the namespace N

    Public Class clsClientInfo
    #Region "Declarations"
    Dim str_LoggedInName As String
    #End Region

    #Region "Logged in as (Properties)"

    Property LoggedInName() As String
    Get
    Return str_LoggedInName
    End Get
    Set(ByVal Value As String)
    str_LoggedInName = Value
    End Set
    End Property
    #End Region

    End Class
    End Namespace

    Yours: Kristoffer
    P.s. Merry christmas to you all! D.s.
    Kristoffer Arfvidson, Dec 19, 2003
    #1
    1. Advertising

  2. Do you have to make it an UserClass to make it work???

    Anybody?

    Yours: Kristoffer...



    "Kristoffer Arfvidson" wrote in message
    news:...
    Hi!
    Don´t know If I ended up on the right server for this question, but Ive been
    looking for ever now for the answer, and please if somebody knows, please
    help me!

    My problem is the following:
    I have an aspx page, called: Page1.aspx
    on top of this page I have the following written line:
    <%@Page language="vb" AutoEventWireup="true" Debug="true" Trace="true"
    inherits="clsCodeBehindIndex" src="page1.aspx.vb" %>

    ok, Now, I have a codebehind page called: Page1.aspx.vb inside witch I have
    for example:
    imports system
    imports system.web
    imports system.web.ui
    imports system.web.ui.webcontrols
    imports system.web.ui.htmlcontrols
    'imports N.clsClientInfo





    public class clsCodeBehindPage
    Inherits System.web.ui.page
    public lbl as label

    sub Page_Load(sender as object,e as eventargs)
    lbl.Text = "page load in Code Behind"

    end sub
    end class


    ------------
    ok, now, I have a third file called: clientinfo.vb witch is on a different
    dir on the server eg. "../Global/clientinfo.vb"
    ok, This is a GLOBAL Class, witch will be accessed thruout the page and
    contains information about the current client. ok...

    So, now to my question, HOW??? on earth do I connect to this class thru my
    codebehind page? (page1.aspx.vb) ??
    I can access the page by using: <%@ Assembly src="../global/clientinfo.vb"
    %> (on the normal aspx page) BUT!
    I cant get access to the class in the codebehind page, ONLY on my normal
    aspx page...

    I try to access the class by typing (in the codebehind page):
    Dim ClientInfo as new clsClientInfo
    But I keep getting error messages...

    OBS!
    I cant use VS.NET since my homepage provider dosnt support dll´s, so, I need
    to make this work, somehow...

    Any suggestions?

    Please help me, I have been looking for a week now, and still havnt found
    any info about this... :(

    Here comes some example code for the clientinfo.vb class:
    Namespace N 'Declare the namespace N

    Public Class clsClientInfo
    #Region "Declarations"
    Dim str_LoggedInName As String
    #End Region

    #Region "Logged in as (Properties)"

    Property LoggedInName() As String
    Get
    Return str_LoggedInName
    End Get
    Set(ByVal Value As String)
    str_LoggedInName = Value
    End Set
    End Property
    #End Region

    End Class
    End Namespace

    Yours: Kristoffer
    P.s. Merry christmas to you all! D.s.
    Kristoffer Arfvidson, Dec 20, 2003
    #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. Vinod Kumar
    Replies:
    5
    Views:
    11,930
    Vinod Kumar
    Dec 29, 2003
  2. vbMark
    Replies:
    5
    Views:
    446
    mortb
    Jun 30, 2004
  3. Mat
    Replies:
    4
    Views:
    369
  4. Replies:
    3
    Views:
    1,338
  5. Paul
    Replies:
    3
    Views:
    1,495
Loading...

Share This Page