• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

Retrieving values after extending the Membership User class

http://msdn2.microsoft.com/en-us/ms366730.aspx

In the above article, it tells how to extend the MembershipUser class with a custom provider...

It says:

"Additionally, you can extend the MembershipUser class to make the added user values available to application code."

In the above example, it is creating two new values:

        Private _IsSubscriber As Boolean
        Private _CustomerID As String

        Public Property IsSubscriber() As Boolean
        Public Property CustomerID() As String

My question is, from within a page page_load or other class or function....

How do I now access this new "IsSubscriber" variable?

If I type "membership." the intellisense doesn't kick in and add the new value to the list of choices? I must not be accessing it properly? I see the others there, but not the new ones. Please help.

thanks.
0
Starr Duskk
Asked:
Starr Duskk
  • 2
2 Solutions
 
anoyesCommented:
I believe what you need to do is cast a variable as your custom user, so for example:

Dim u As CustomUser = Membership.GetUser(Page.User.Identity.Name)
Dim IsSubscriber As Boolean = u.IsSubscriber
0
 
samtran0331Commented:
>>If I type "membership." the intellisense doesn't kick in and add the new value to the list of choices?
If you:
Dim u As CustomUser = Membership.GetUser(Page.User.Identity.Name)

You are still using the default MS provider, not the custom one...

If you're using that exact sample class MS provided (because they wrapped it in a namespace), from a page, you would get the the "IsSubscriber" property with (I faked the parameters to be able to Dim the myUser object):

        Dim key As New Object
        Dim myUser As New Samples.AspNet.Membership.VB.OdbcMembershipUser("providername", "username", key, "email", "pwdQ", "comment", True, False, Now, Now, Now, Now, Now, True, "custID")
        myUser.IsSubscriber = True


0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
samtran,

But you're passing in all the stuff just to retrieve it again. I want to use it from when I logged in. I created the user when I logged in. Now I should be able to use it within redefining it shouldn't I?

I mean, what's the point of creating a new user to retrieve that stuff if I already have it handy right there. Why don't I just use the value I'm passing in. It doesn't make sense.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Okay, I did annoyes version of GetUser() combined with samtran's custom namespace stuff and that's what I need.

I only need to pass in the username, because I've already defined everything else in my membershipprovider once, and so using the username only is all I need once they've logged in.

thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now