TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
olabanji aribisala
NA
12
1k
How to get a specific user profile through user identifier
Aug 27 2015 4:41 AM
I'm working on an asp.net application I'm currently working on the administrator
page. As an administrator i need to retrieve a specific user information stored
within profile property in web.config. I used ProfileCommon class with GetProfile
method that i built my self because that class and method are not in .Net
framework Don't mind my terminology I'm still a novice
<profile>
<properties>
<add name="PostalCode" type="System.String" />
<add name="Country" type="System.String" />
</properties>
</profile>
This is how i define the class, properties and GetProfile method
public class ProfileCommon : ProfileBase
{
public string PostalCode
{
get
{
return (string)HttpContext.Current.Profile.GetPropertyValue
("PostalCode");
}
set
{
HttpContext.Current.Profile.SetPropertyValue("PostalCode", value);
}
}
public string Country
{
get
{
return (string)HttpContext.Current.Profile.GetPropertyValue("Country");
}
set
{
HttpContext.Current.Profile.SetPropertyValue("Country", value);
}
}
public virtual ProfileCommon GetProfile(string username)
{
return Create(username) as ProfileCommon;
}
}
This is how I'm trying to retrieve information on a specific user
// I retrieved the unique identifier of a user in my Order table.
Customer = Membership.GetUser(new Guid(orderRow["CustomerID"].ToString()));
// I try to use it to retrieve a user specific info stored in web.config
ProfileCommon pro = new ProfileCommon();
CustomerProfile = pro.GetProfile(Customer.UserName);
postalCodeLabel.Text = CustomerProfile.PostalCode;
countryLabel.Text = CustomerProfile.Country;
please is their any other way I can retrieve this information or is there anything I'm
not doing right cos I'm suspecting the definition of my GetProfile method. I will really appreciate it if I can get the solution to this problem
Reply
Answers (
1
)
Net code is Compiles.......
How To Read and BindData Text File To GridView Using Asp.net