Create Profile. Need advice ...

Discussion in 'ASP .Net' started by shapper, Jan 16, 2007.

  1. shapper

    shapper Guest

    Hello,

    I have a profile with multiple profile properties in my Web.Config:

    <add allowAnonymous="false" name="Contact" type="Contact"
    serializeAs="Binary"/>
    <add allowAnonymous="false" name="Options" type="Options"
    serializeAs="Binary"/>

    Where each profile property is class, as follows:

    <Serializable()> _
    Public Class Contact
    Inherits ProfileBase

    ' City
    Public Property City() As String
    Get
    Return CType(Me("City"), String)
    End Get
    Set(ByVal value As String)
    Me("City") = value
    End Set
    End Property ' City
    ...

    End Class

    I am creating a new profile to a user which I just created as follows:

    Dim myContact As Contact = CType(ProfileBase.Create(username), Contact)
    With myContact
    .City = tbCity.Text
    ...
    End With
    contact.Save()

    My question is:

    Do I need to repeat this code to all my profile properties or is there
    a better way to do this?

    I have been Goggling for information on how to create a new profile for
    a user which have been just created where there are various properties
    and all them are custom classes.

    Any advice would be great.

    Thanks,

    Miguel
     
    shapper, Jan 16, 2007
    #1
    1. Advertising

  2. If you are making individual classes that store in profile, you will have to
    work each one separately and add to profile. You can get around repeating
    this in multiple locations, by setting up a class that holds the
    save/retrieve profile information, but you will still have to have the code
    for each class you are serializing into the profile.

    Hope I answered the question you were asking. :)

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    ********************************************
    Think outside the box!
    ********************************************
    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I have a profile with multiple profile properties in my Web.Config:
    >
    > <add allowAnonymous="false" name="Contact" type="Contact"
    > serializeAs="Binary"/>
    > <add allowAnonymous="false" name="Options" type="Options"
    > serializeAs="Binary"/>
    >
    > Where each profile property is class, as follows:
    >
    > <Serializable()> _
    > Public Class Contact
    > Inherits ProfileBase
    >
    > ' City
    > Public Property City() As String
    > Get
    > Return CType(Me("City"), String)
    > End Get
    > Set(ByVal value As String)
    > Me("City") = value
    > End Set
    > End Property ' City
    > ...
    >
    > End Class
    >
    > I am creating a new profile to a user which I just created as follows:
    >
    > Dim myContact As Contact = CType(ProfileBase.Create(username), Contact)
    > With myContact
    > .City = tbCity.Text
    > ...
    > End With
    > contact.Save()
    >
    > My question is:
    >
    > Do I need to repeat this code to all my profile properties or is there
    > a better way to do this?
    >
    > I have been Goggling for information on how to create a new profile for
    > a user which have been just created where there are various properties
    > and all them are custom classes.
    >
    > Any advice would be great.
    >
    > Thanks,
    >
    > Miguel
    >
     
    Cowboy \(Gregory A. Beamer\), Jan 16, 2007
    #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. Miguel Dias Moura
    Replies:
    0
    Views:
    372
    Miguel Dias Moura
    Jan 28, 2006
  2. Brad
    Replies:
    1
    Views:
    1,179
    Roedy Green
    Jul 19, 2005
  3. shapper
    Replies:
    5
    Views:
    424
    Karl Seguin
    Nov 30, 2006
  4. Andy B
    Replies:
    0
    Views:
    558
    Andy B
    May 3, 2008
  5. Steven
    Replies:
    5
    Views:
    514
    Steven
    Oct 24, 2008
Loading...

Share This Page