Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3975574
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:42:05+00:00 2026-05-20T04:42:05+00:00

I am using asp.net membership and trying to update a users details but get

  • 0

I am using asp.net membership and trying to update a users details but get the following error:

Error    2    Overload resolution failed because no accessible 'New' accepts this number of arguments. 

Below is the full .vb code:

Partial Class FamilyAdmin_edit_user
    Inherits System.Web.UI.Page

    Private username As String

    Dim user As MembershipUser

    Private Sub Page_Load()
        username = Request.QueryString("username")
        If username Is Nothing OrElse username = "" Then
            Response.Redirect("users.aspx")
        End If
        User = Membership.GetUser(username)

        UserUpdateMessage.Text = ""
    End Sub

    Protected Sub UserInfo_ItemUpdating(ByVal sender As Object, ByVal e As DetailsViewUpdateEventArgs)
        'Need to handle the update manually because MembershipUser does not have a
        'parameterless constructor  

        user.Email = DirectCast(e.NewValues(0), String)
        user.Comment = DirectCast(e.NewValues(1), String)
        user.IsApproved = CBool(e.NewValues(2))

        Try
            ' Update user info:
            Membership.UpdateUser(user)

            ' Update user roles:
            UpdateUserRoles()

            UserUpdateMessage.Text = "Update Successful."

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        Catch ex As Exception
            UserUpdateMessage.Text = "Update Failed: " + ex.Message

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        End Try
    End Sub

    Private Sub Page_PreRender()
        ' Load the User Roles into checkboxes.
        UserRoles.DataSource = Roles.GetAllRoles()
        UserRoles.DataBind()

        ' Disable checkboxes if appropriate:
        If UserInfo.CurrentMode <> DetailsViewMode.Edit Then
            For Each checkbox As ListItem In UserRoles.Items
                checkbox.Enabled = False
            Next
        End If

        ' Bind these checkboxes to the User's own set of roles.
        Dim userRoles__1 As String() = Roles.GetRolesForUser(username)
        For Each role As String In userRoles__1
            Dim checkbox As ListItem = UserRoles.Items.FindByValue(role)
            checkbox.Selected = True
        Next
    End Sub

    Private Sub UpdateUserRoles()
        For Each rolebox As ListItem In UserRoles.Items
            If rolebox.Selected Then
                If Not Roles.IsUserInRole(username, rolebox.Text) Then
                    Roles.AddUserToRole(username, rolebox.Text)
                End If
            Else
                If Roles.IsUserInRole(username, rolebox.Text) Then
                    Roles.RemoveUserFromRole(username, rolebox.Text)
                End If
            End If
        Next
    End Sub

    Public Sub DeleteUser(ByVal sender As Object, ByVal e As EventArgs)
        'Membership.DeleteUser(username, false); // DC: My apps will NEVER delete the related data.
        Membership.DeleteUser(username, True)
        ' DC: except during testing, of course!
        Response.Redirect("manage_members.aspx")
    End Sub

    Public Sub UnlockUser(ByVal sender As Object, ByVal e As EventArgs)
        ' Dan Clem, added 5/30/2007 post-live upgrade.

        ' Unlock the user.
        User.UnlockUser()

        ' DataBind the GridView to reflect same.
        UserInfo.DataBind()
    End Sub

End Class

Before i had:

 Dim user As MembershipUser

and got the error:

Object reference not set to an
instance of an object. Description: An
unhandled exception occurred during
the execution of the current web
request. Please review the stack trace
for more information about the error
and where it originated in the code.

Exception Details:
System.NullReferenceException: Object
reference not set to an instance of an
object.

Source Error:

Line 20: ‘parameterless
constructor Line 21: Line 22:
user.Email =
DirectCast(e.NewValues(0), String)
Line 23: user.Comment =
DirectCast(e.NewValues(1), String)
Line 24: user.IsApproved =
CBool(e.NewValues(2))

I apologise for my lack of programming knowledge. Could you please point out where i need to change my code to be able to update the users details?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:42:06+00:00Added an answer on May 20, 2026 at 4:42 am

    In Membership.GetUser(username) you need to add a second parameter IsUserOnline (Boolean):
    Membership.GetUser(username, true)

    The variable Membership is initialized with a Membership.Provider?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC Framwork and trying to grok the ASP Membership 3.5 stuff.
I am using ASP.net membership, but I want to store additional information for client
I'm using ASP.NET membership for a site that will serve primarily sophisticated users. I
I'm trying to deploy a website using ASP.NET membership and the hosting company is
I'm using the ASP.Net Membership system but I'm having an issue with the LastActivityDate
I'm using ASP.NET Membership and noticed there isn't a method in the Roles class
I'm using asp.net membership, and need to make a call to Membership.GetUser() while I
Is there any framework/library for using ASP.NET Membership Provider with confirmation email, something ready
I am using the ASP.NET membership provider controls (ChangePassword and PasswordRecovery) and they generally
I have this membership site setup on my local machine using the ASP.NET membership

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.