Solved

How to add/update an ASP.NET membership user profile?

Posted on 2010-09-17
3
843 Views
Last Modified: 2012-05-10
I am developing an admin interface that allow an admin user to create a number of user accounts (using ASP.NET Membership) and specify profile information for each user, e.g. first name, last name, client name, etc. I have been experimenting with the SqlTableProfileProvider, since this creates separate fields in a database table.  

However, when I am creating the profile and assign values to the profile using, e.g. Profile.FirstName it is setting my profile information, i.e. the current logged in user.

How do I add/update profile information for a user account?  The user will also update sectios of their profile, but the admin needs to be able to update all user profiles.

Thanks.
0
Comment
Question by:markerasmus
3 Comments
 
LVL 16

Expert Comment

by:kris_per
ID: 33700258

You can use ProfileBase.Create method to get the Profile of other users.

For e.g:

MyCustomProfile myProfile = (MyCustomProfile)ProfileBase.Create("username");
myProfile.ZipCode = "98052";
myProfile.Save();


msdn sample and documentation here => http://msdn.microsoft.com/en-us/library/ms151825.aspx

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33702360
What said kris_pe is correct you will need to create profile manually but here is an example which does same using CUW:
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

It uses ProfileCommane class:

ProfileCommon p = (ProfileCommon) ProfileCommon.Create(username);
p.FirstName="FirstName";
p.Save();
0
 

Accepted Solution

by:
markerasmus earned 0 total points
ID: 33726775
Because I am using SqlTableProfileProvider I ended up writing my own update queries to update the database table.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 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