I've previously posted a demo that illustrated a tag cloud web part, I've now posted the code.
First let me warn you that the method I've used to get the tag list will not scale, so please disregard the TagBuilder method, you'll need to implement that yourself.
I've based this tag cloud control loosely on the tag cloud control from codeproject, I've refactored most of it, but have kept the maths behind generating a weighting.
Using the control is pretty simple, you just need to measure the tags and then pass in a collection of CloudItems:
//tagList is a dictionary with the tag and count Dictionary<string, int> tagList = new Dictionary<string, int>(); foreach (string tag in tagList.Keys) { CloudItem cloudItem = new CloudItem(); cloudItem.Text = tag; cloudItem.Weight = tagList[tag]; cloudItem.Href = "/SearchCenter/Pages/Results.aspx?k=tags:" + tag; Items.Add(cloudItem); }
There are a number of ways to perform the measurement, if you were to count the number of times a tagged resource was accessed, you would end up with a heat map of popular items. Alternatively you could simply count up the number of times a tag has been used (I think this is the most common use, I've done it this way in my demo). In any case the exact implementation details have been left up to you.