Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

'GetUser' is not a member of 'membership'

Posted on 2009-05-08
8
Medium Priority
?
937 Views
Last Modified: 2017-02-09
Hi all,

I was taking an Intro to ASP.NET online class. There is a lesson where we create a login page, but I am getting an error about the 'GetUser' attribute of the Membership class.  Am I missing a namespace or something?  I know that "GetUser" is a member of the Membership class as stated here:  http://msdn.microsoft.com/en-us/library/system.web.security.membership.getuser(VS.80).aspx, but I can't figure out why I'm getting the squiggly lines under "GetUser" and the compile errors.

After the user creates their login, they can view their profile or edit their profile. Well, when I create a user, I am getting the following errors when I click on the "view profile" or "edit profile" links.  I can not view those pages.  Could someone help me with this?

Here is the error for VIEWPROFILE.ASPX:


 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'GetUser' is not a member of 'membership'.

Source Error:

Line 5:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Line 6:          If Request("UserId") Is Nothing Then
Line 7:              SqlDataSource1.SelectParameters(0).DefaultValue = membership.GetUser.Provider
Line 8:              
Line 9:          End If


Source File: C:\myweb\MemberPages\viewprofile.aspx    Line: 7


Here is the error for EDITPROFILE.ASPX
 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'GetUser' is not a member of 'membership'.

Source Error:

Line 5:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 6:          Dim UserID As String
Line 7:          UserID = membership.GetUser.ProviderUserKey.ToString
Line 8:          SqlDataSource2.SelectParameters("UserID").DefaultValue = UserID
Line 9:          FormView1.DataSource = SqlDataSource2


Source File: C:\myweb\MemberPages\editprofile.aspx.vb    Line: 7
Here is the code for VIEWPROFILE.ASPX
 
<%@ Page Title="" Language="VB" MasterPageFile="~/membership.master" %>
 
<script runat="server">
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Request("UserId") Is Nothing Then
            SqlDataSource1.SelectParameters(0).DefaultValue = membership.GetUser.Provider
            
        End If
    End Sub
</script>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
    <ItemTemplate>
    <img src="<%#Eval("ImageAddress"> %>" />
    <%#Eval("ProfileText")%>
    
    </ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ASPNETDB %>" 
        SelectCommand="SELECT * FROM [Profiles] WHERE ([UserID] = @UserID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="UserID" QueryStringField="UserId" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
 
 
 
 
 
 
Here is code-behind for EDITPROFILE.ASPX.VB
 
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim UserID As String
        UserID = membership.GetUser.ProviderUserKey.ToString
        SqlDataSource2.SelectParameters("UserID").DefaultValue = UserID
        FormView1.DataSource = SqlDataSource2
        FormView1.DataBind()
 
 
    End Sub
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim UserID As String
        UserID = membership.GetUser.ProviderUserKey.ToString
        SqlDataSource2.UpdateParameters("UserID").DefaultValue = UserID
        SqlDataSource2.UpdateParameters("ImageAddress").DefaultValue = TextBox1.Text
        SqlDataSource2.UpdateParameters("ProfileText").DefaultValue = TextBox2.Text
        If SqlDataSource2.Update() = 0 Then
            SqlDataSource2.InsertParameters("UserID").DefaultValue = UserID
            SqlDataSource2.InsertParameters("ImageAddress").DefaultValue = TextBox1.Text
            SqlDataSource2.InsertParameters("ProfileText").DefaultValue = TextBox2.Text
            SqlDataSource2.Insert()
        End If
        SqlDataSource2.SelectParameters("UserID").DefaultValue = UserID
        FormView1.DataSource = SqlDataSource2
        FormView1.DataBind()
 
    End Sub

Open in new window

0
Comment
Question by:NorthArrow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 3

Expert Comment

by:SalmanZG
ID: 24342693
GetUser is a function.
Try GetUser()
0
 

Author Comment

by:NorthArrow
ID: 24346845
GetUser is a function.
Try GetUser()

????

SalmanZG, would you provide exactly how to code this?

FYI to Experts Exchange forum:  

I'm a student of ASP.NET.  The code I provided has been copied and pasted from the online class courseware.  I'm trying to complete an assignment and this is code that is supposed to work, but I am getting an error.  Since the discussion is closed, I can't ask my fellow students or the instructor, therefore, I seek your help.

Thanks in advance.
0
 
LVL 3

Expert Comment

by:SalmanZG
ID: 24355530
Try changing line 7 to:
UserID = membership.GetUser().ProviderUserKey.ToString
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:NorthArrow
ID: 24358718
Thanks, SalmanZG, I will try that.  Should I put replace all GetUser with GetUser()?  It is in more than one place

0
 

Author Comment

by:NorthArrow
ID: 24360004
SalmanZG, including the "()" does not work.  Attached is a screen shot.
mem-code.GIF
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 24375660
you must either import the membership definition or use the full name as in

System.Web.Security.Membership.GetUser()
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 2000 total points
ID: 24375707
To import it you would add
Imports System.Web.Security.Membership
at the top of the code before the Class statement.

0
 

Author Comment

by:NorthArrow
ID: 24379210
Thanks, JohnBPrice,  I thought a namespace had to be added (although I didn't know what it was called) and that is the answer I was seeking.  I don't know why our instructor did not include that step.  I will do the import and let you know what happens.  I'm going to do the assignment from scratch for a clean start.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

609 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