Solved

Retrieving values after extending the Membership User class

Posted on 2007-11-30
4
567 Views
Last Modified: 2010-05-18
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
Comment
Question by:BobCSD
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 250 total points
ID: 20385194
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
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 250 total points
ID: 20385666
>>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
 
LVL 1

Author Comment

by:BobCSD
ID: 20385708
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
 
LVL 1

Author Comment

by:BobCSD
ID: 20385770
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now