Dave Burke : Freelance .NET Web Developer specializing in Online Communities

CS Nuglet: Quick access to extended user profile properties

A lot of good information is out there on extended user profile properties.  Check out this DN List Blog search result list, for instance.  Do we seriously need another nuglet of this?  Indulge me.

Let's say we want to modify the Users Member directory and add an extended user property like their location.  First thought might be


CSContext.Current.User.GetExtendedAttribute("Location"),true))


But then, how would we know it's "Location" and not "UserLocation" or something else.  Well, profile properties are listed in the <profile /> section of the web.config.

 

<profile>
<properties>
<add name = "commonName" type = "string" />
<add name = "birthdate" type = "DateTime" />
<add name = "gender" type = "int" defaultValue = "0" />
<add name = "location" type = "string" />
...
</properties>
</profile>

 

Let the nuglet breathe a bit and we learn that there is a User Profile class, so forget everything we just said.  Full intellisense for all CS-supported user extended profile properties for adding a "Location" column to the Member Grid, like so.

 

Literal Location = e.Item.FindControl("Location") as Literal;
if (Location != null)
{
if (!Globals.IsNullorEmpty(user.Profile.Location))
   {
      Location.Text = user.Profile.Location;
   }
}

Comments (0) | Post RSS RSS comment feed

Posted on 1/24/2007 6:43:13 AM by Dave Burke
Categories: Community Server
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke