Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 3rd, 2007, 12:29 PM
Authorized User
 
Join Date: Sep 2007
Location: Quito, Pichincha, Ecuador.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Membership.UpdateUser()

Hi everybody,
I am trying to update users data using the UpdateUser method into ASPNET.MDF(the default database that is created when createuserwizard control is used). The problem is when I try to update the user username, I get this error:
'System.Web.Security.MembershipUser' does not contain a definition for 'Username'. Is it impossible to change username or other information when a user is already created? Any help or comment would be great!!!
I already tried changing email did it right
        :) what is wrong with username?

Here is the code I put in the update button onclick event:

user.Username = ((TextBox)this.Master.FindControl("ContentPlaceHol der1").FindControl("txt1")).Text;
        Membership.UpdateUser(user);
  #2 (permalink)  
Old October 3rd, 2007, 12:45 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You cannot update the Username, once a user is created, it's readonly. Because it's used as a primary key it would invlove a lot of code and database checks. To get around this you'd have to create a new User object and override the provider to allow for this possibility.

--

Joe (Microsoft MVP - XML)
  #3 (permalink)  
Old October 3rd, 2007, 01:14 PM
Authorized User
 
Join Date: Sep 2007
Location: Quito, Pichincha, Ecuador.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank Joe you have been very helpful to me and I appreciate that!
The thing is that I am a new using ASP.NET and I didn't get the meaning of "override the provider". I don't know if its possible for you to provide me some extra information just to have an idea and keep looking for a solution.

Regards
  #4 (permalink)  
Old October 3rd, 2007, 02:27 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you're new to this then I'd steer clear unless you have to. You can write your own provider that inherits from a built-in one or just from scratch. I did it once and it's no small task but in your case it's probably not too difficult. You'd have to do something similar with the MembershipUser too. There are articles on msdn2.com about the asp.net 2.0 membership provider model and also a fantastic Wrox book on it (wish I'd read it before I started on the task, Professional ASP.NET 2.0 Security, Membership, and Role Management, not sure if it's still available outside of one of their packages though: http://www.wrox.com/WileyCDA/WroxTit...470117575.html.

--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
Membership Troubleshooting Laenas1979 ASP.NET 2.0 Professional 0 July 3rd, 2007 01:29 PM
Help with membership Provider... slim182 ASP.NET 2.0 Basics 1 February 19th, 2007 10:15 AM
Membership security Maxxim ASP.NET 2.0 Professional 1 February 13th, 2007 10:39 PM
Membership and different applications Maxxim BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 February 12th, 2007 11:35 PM
membership provider davyquyo ASP.NET 2.0 Basics 0 January 1st, 2007 04:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.