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

CS Nuglet: Linking the Forum User Avatar to User Profile

One of my clients asked me to "fix" the Forums User Avatar so that it links to the user's profile.  An interesting request, and they were right.  They Avatar should probably link to the user's profile, like the username listed above it does.  So we fixed it.

The <CS:UserAvatar /> control is used to display the avatar, so it was a chance to write a new DBVT:UserAvatar class.  Woot!  The CS:UserAvatar control creates an HtmlImage control to display the Avatar when the page is rendered.  Pretty slick, actually, considering that the User Avatar image isn't stored in a web directory but in the cs_UserAvatar table's content field.

The complete DBVT.UserAvatar class file is located here, basically pulling the CS:UserAvatar core and wrapping the Image in Hyperlink tags fore and aft.  Not elegant, but it supports all CS:UserAvatar properties and page formatting options.


avatarLinkStart.Text = "<a href=\"" + Globals.GetSiteUrls().UserProfile(this.User.Username) + "\">"
avatarLinkStart.RenderControl(writer);
image.RenderControl(writer);
avatarLinkEnd.Text = "</a>"
avatarLinkEnd.RenderControl(writer);


Apart from that we register the control and modify the HTML.

 

<%@ Register TagPrefix="DBVT" Namespace="DBVT.Controls" Assembly="DBVT" %>

<DBVT:UserAvatar runat="server" Border="1" PadImage="False" id="Avatar" />


There, all fixed!

Comments (0) | Post RSS RSS comment feed

Posted on 3/3/2007 8:49:36 PM by Dave Burke
Categories: Community Server
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke