Solved

Retrieving values after extending the Membership User class

Posted on 2007-11-30
4
570 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:Starr Duskk
  • 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 2

Author Comment

by:Starr Duskk
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 2

Author Comment

by:Starr Duskk
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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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