Solved

Retrieving values after extending the Membership User class

Posted on 2007-11-30
4
569 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

821 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