Profile Properties not visible in VB Class module?

Last post 04-01-2008 9:18 PM by mpdillon. 13 replies.

Sort Posts:

  • Profile Properties not visible in VB Class module?

    01-29-2008, 7:58 PM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    I am using a VB Class module to store repeated functions. Within these functions I would like to access the properties of the Profile which I created in the web.config file. When I am in the VB class and type "Profile." intellisense does not list the properties. However, if I go to a web page and type "Profile." then intellisense lists the properties I created in the web.config file. Do I need to add an Imports or Inherits to the VB class module? If so what would it look like? Or is tsomething else?

    thanks,

    pat

  • Re: Profile Properties not visible in VB Class module?

    01-29-2008, 11:45 PM
    Did you instantiate your class? Usually, to make your class visible by the current class you are in, you need to instantiate a class. For example, Class Structure:
    Currently in VB, classes are created in individual files. When you add a class to a project VB adds a corresponding file to the project. In VB.NET classes are not dependent on files, rather they are declared in Class statement blocks. Multiple classes can be declared within one file. Here are two classes that may be defined in one file:  Class Order        Public ID As Long        Public ShippingAddress As String        Function ExecuteOrder(Value as Integer) As Boolean                               'code for function goes here        End FunctionEnd Class In addition, all classes in VB.NET have a sub procedure called New. It is run when a class is initially created and is known as a Constructor. It replaces VB's Class_Initialize procedure. The New constructor, unlike Class_Initialize, can only run once and cannot be called a second time after the class has been initialized.  Class OrderPublic ID As LongPublic ShippingAddress As StringSub New (OrderID as Long)               mybase.NewID=OrderIDEnd SubFunction ExecuteOrder(Value as Integer) As Boolean                               'code for function goes here     End FunctionEnd Class This class would be instantiated with the following code:  Dim objOrder as OrderobjOrder= New Order(4323)

    Now, if you have instantiated your class, you will have to inherit the functionality of your current class. Let me know and I'll send you more information.

     

    Eduardo

    Thanks,

    Please Mark this post as answered if it was helpful.
  • Re: Profile Properties not visible in VB Class module?

    01-30-2008, 6:26 AM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    Eduardo,

    When I use my VB class in a aspx.vb file I do instanciate the class with NEW. Thanks for the explanation because I did not know how it worked until you explained it.

    The problem I am having is with State Management. When I try to use Profile I can see Profile properties in my aspx.vb files(the code file behind the web page) but not in VB class that has been added to the project and stored in the APP_Code folder.

  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 10:03 AM

    Are you using inheritance? Let me know.

    Thanks,

    Please Mark this post as answered if it was helpful.
  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 10:45 AM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    The only inheritance I put in my VB class is:

    Inherits System.web.UI.page

     

    Actual code:

    Public Class LogInCtl
        Inherits System.Web.UI.Page
        Public Sub LogIn()

     

    However, the Profile is defined in the web.config file. I do not know a how to reference(inherit) the web.config file in the VB class.

    When coding in the code behind file(Default.aspx.vb) and not the seperate VB class(LogIn.vb), the properties of the Profile defined in the web.config file automatically appear.

    Thanks for your continued support as it appears no one else has the answer.

    As a test I created a new web app. Added the profile code to the web.config. Tested that the Profile intellisense worked in the Default.aspx.vb. I then added a VB class, Class1.vb. I created a public sub procedure. I tried to use Profile but its properties as defined in the web.config file were not present.

    pat

  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 10:45 AM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    The only inheritance I put in my VB class is:

    Inherits System.web.UI.page

     

    Actual code:

    Public Class LogInCtl
        Inherits System.Web.UI.Page
        Public Sub LogIn()

     

    However, the Profile is defined in the web.config file. I do not know a how to reference(inherit) the web.config file in the VB class.

    When coding in the code behind file(Default.aspx.vb) and not the seperate VB class(LogIn.vb), the properties of the Profile defined in the web.config file automatically appear.

    Thanks for your continued support as it appears no one else has the answer.

    As a test I created a new web app. Added the profile code to the web.config. Tested that the Profile intellisense worked in the Default.aspx.vb. I then added a VB class, Class1.vb. I created a public sub procedure. I tried to use Profile but its properties as defined in the web.config file were not present.

    pat

     
  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 10:45 AM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    The only inheritance I put in my VB class is:

    Inherits System.web.UI.page

     

    Actual code:

    Public Class LogInCtl
        Inherits System.Web.UI.Page
        Public Sub LogIn()

     

    However, the Profile is defined in the web.config file. I do not know a how to reference(inherit) the web.config file in the VB class.

    When coding in the code behind file(Default.aspx.vb) and not the seperate VB class(LogIn.vb), the properties of the Profile defined in the web.config file automatically appear.

    Thanks for your continued support as it appears no one else has the answer.

    As a test I created a new web app. Added the profile code to the web.config. Tested that the Profile intellisense worked in the Default.aspx.vb. I then added a VB class, Class1.vb. I created a public sub procedure. I tried to use Profile but its properties as defined in the web.config file were not present.

    pat

     
  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 10:47 AM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    Wow. I hit the back space key once while editing and my reply was posted 3 times. Sorry.

    The actual code in my project is:

    Public Class LogInCtl

    Inherits system.web.ui.page

    public sub LogIn

    Profile.   and no intelisense after the period.

    end sub

    end class

     

  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 11:44 AM

    This is what I think,

    Why don't you create a class (public) and write the code you want to run from the web.config file. Once this class is created, instatiate it in the class you want the profile to execute. Also, you can inherit form the new created class. The reason I'm telling you this is because I've faced situations in where I needed to create my custom "solutions" to problem. Let me know what you think.

     

    Thanks,

    Please Mark this post as answered if it was helpful.
  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 1:23 PM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    I don't believe I can add a class to the web.config file. It is an XML file. So I must not be understanding what you are suggesting.

  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 1:38 PM

    Oh no ... I meant a class in your program with the functionality that you want to have for the passwrod text box. This is, instead of configuring the web config file, just create your own procedure in a different class. Then you can inherit all the functionality of your new class in your current class. I'm trying to look for the code that will allow you to do this ... I'm learning a lot myself by trying to figure this with you ... so it's ok ... the only constraint is my work ... so probably I'll need to do it over the weekend .... if you get the answer before then, I would apprecite it if you could share it.

     Eduardo

    Thanks,

    Please Mark this post as answered if it was helpful.
  • Re: Profile Properties not visible in VB Class module?

    01-31-2008, 6:52 PM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33

    Again thanks for your help. It is not functionality such as password encryption or date manipulation that I am having difficulty. It is State Management. Previously, I used the Session state to store information I did not want lost during a post back. I thought I would try Profile properties as an alternative this time.

    See the following video for more details.

    http://www.asp.net/learn/videos/video-11.aspx

    Profiles offered me the ability to consume less memory on the server and to use SQL server to store the information. It was worth trying but I cannot seem to get it to work.

    I will let you know if I solve the issue. Please do the same.

    thanks,

    pat

     

  • Re: Profile Properties not visible in VB Class module?

    02-04-2008, 7:03 AM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 8:31 AM
    • Jerusalem
    • Posts 4,069

    hi

    to access the profile from the other classes , use this syntax:

     

    Public Class AnyClass
    
    
        Public Sub AnyMethod()
            Dim currentProfile As ProfileCommon = CType(HttpContext.Current.Profile, ProfileCommon)
    
            currentProfile.FirstProperty=....
            .
        End Sub
    
    End Class

     

    Note :visual studio will update the profileCommon class every time you change the profile properties in your web.config file .

     

    Best Regards,

    Anas Ghanem| LogFile
  • Re: Profile Properties not visible in VB Class module?

    04-01-2008, 9:18 PM
    • Loading...
    • mpdillon
    • Joined on 01-28-2008, 10:18 PM
    • Posts 33
    That was a very close answer. It did not work for me as shown. I added New to the DIM statement and it worked exactly as below.
    Public Class AnyClass

    Public Sub AnyMethod()

    Dim currentProfile As New ProfileCommon

    currentProfile = CType(HttpContext.Current.Profile, ProfileCommon)
    currentProfile.FirstProperty=....

    End Sub

    End Class

    Thanks again.
Page 1 of 1 (14 items)