How to implement Tagging in Web 2.0

A tag, according to Wikipedia, is “a (relevant) keyword or term associated with or assigned to a piece of information (e.g. a picture, article, or video clip), thus describing the item and enabling keyword-based classification of information.” Simply tags are like keyword or category labels, and they can help visitors find items which have something in common.

Here is the how you can implement tags using asp.net. You can put the tags on the database for each item. And you can use repeater to dispay the tags. Most important thing is you need different font size for each tag so that user can easily distinguish between them. Larget fonts usually means more popular keywords. You can create a set of 3-4 font size and set them randomly for each item on repeater. Here is the sample code. I have used here the object datasoure. You can switch to for your own binding.

Aspx code

		

 





 

Code behind

		Partial Class PageName    Inherits Page
  Dim obj As New Random()
         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       End Sub
     Protected Function GetKeywordSize() As Integer
         Return obj.Next(12, 18)
    End Function
     Protected Function GetFontWeight() As Integer
        Return obj.Next(100, 1000)
    End Function End Class 
blog comments powered by Disqus