aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Asp.Net Tag Cloud Example with Database in C#,VB.NET

Jul 18, 2014

Here I will explain how to create tag cloud in website using jQuery, c#, with example or generate tag cloud in with database using jQuery, c#,


In previous post I explained sitemap control example,
send html page as mail body in, send mail with images using gmail user credentials, send multiple attachments with email in, how to send mail with attachment in and many more articles related to using c#, Now I will explain how to how to create tag cloud in website using jQuery, c#, with example.

To create tag cloud in website first create new website and write follwing code in Default.aspx page

<html xmlns="">
<title>Tag Cloud in using C#</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
type: "POST",
url: "Default.aspx?type=gettags",
data: "{}",
success: function(data) {
error: function(result) {
<style type="text/css">
font-family: Arial;
font-size: 8px;
color: #000;

font-family: Arial;
font-size: 12px;
color: #000;

font-family: Arial;
font-size: 16px;
color: #000;

font-family: Arial;
font-size: 20px;
color: #000;
<form id="form1" runat="server">
<div id="tagsdiv" style="width:50px">

After completion of aspx page write the following code in codebehind

C# Code

using System;
using System.Data;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
string type = Request["type"];
string ReturnDataType = "application/html" ;
string rJson = GetTagDetails();
Response.ContentType = ReturnDataType;
public string GetTagDetails()
DataTable dt = new DataTable();
dt.Columns.Add("Tagid", typeof(Int32));
dt.Columns.Add("TagName", typeof(string));
dt.Columns.Add("Noofarticles", typeof(string));
dt.Rows.Add(1, "Asp.Net", 100);
dt.Rows.Add(2, "C#.Net", 10);
dt.Rows.Add(3, "SQL Server", 30);
dt.Rows.Add(4, "jQuery", 20);
dt.Rows.Add(6, "javascript", 15);
dt.Rows.Add(7, "XSLT", 50);
string strleadDetails = string.Empty;
for (int i = 0; i < dt.Rows.Count; i++)
int j = Convert.ToInt32(dt.Rows[i][2].ToString());
if (j <= 10)
strleadDetails += "<a href=javascript:void(0) class=TagSize1>" + dt.Rows[i][1] + "</a>";
else if (j > 10 && j <= 20)
strleadDetails += "<a href=javascript:void(0) class=TagSize2>" + dt.Rows[i][1] + "</a>";
else if (j > 20 && j <= 50)
strleadDetails += "<a href=javascript:void(0) class=TagSize3>" + dt.Rows[i][1] + "</a>";
else if (j > 50 && j <= 100)
strleadDetails += "<a href=javascript:void(0) class=TagSize4>" + dt.Rows[i][1] + "</a>";
return strleadDetails;

Imports System.Data
Partial Class vbcode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim type As String = Request("type")
Dim ReturnDataType As String = "application/html"
If type = "gettags" Then
Dim rJson As String = GetTagDetails()
Response.ContentType = ReturnDataType
End If
End Sub
Public Function GetTagDetails() As String
Dim dt As New DataTable()
dt.Columns.Add("Tagid", GetType(Int32))
dt.Columns.Add("TagName", GetType(String))
dt.Columns.Add("Noofarticles", GetType(String))
dt.Rows.Add(1, "Asp.Net", 100)
dt.Rows.Add(2, "C#.Net", 10)
dt.Rows.Add(3, "SQL Server", 30)
dt.Rows.Add(4, "jQuery", 20)
dt.Rows.Add(6, "javascript", 15)
dt.Rows.Add(7, "XSLT", 50)
Dim strleadDetails As String = String.Empty
For i As Integer = 0 To dt.Rows.Count - 1
Dim j As Integer = Convert.ToInt32(dt.Rows(i)(2).ToString())
If j <= 10 Then
strleadDetails += "<a href=javascript:void(0) class=TagSize1>" + dt.Rows(i)(1) + "</a>"
ElseIf j > 10 AndAlso j <= 20 Then
strleadDetails += "<a href=javascript:void(0) class=TagSize2>" + dt.Rows(i)(1) + "</a>"
ElseIf j > 20 AndAlso j <= 50 Then
strleadDetails += "<a href=javascript:void(0) class=TagSize3>" + dt.Rows(i)(1) + "</a>"
ElseIf j > 50 AndAlso j <= 100 Then
strleadDetails += "<a href=javascript:void(0) class=TagSize4>" + dt.Rows(i)(1) + "</a>"
End If
Return strleadDetails
End Function
End Class

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


sunil said...

sir i want to know how keep submenu open when page change in jquery.

Rakesh Raju said...

Good one

Kyaw Khaung said...

How do you create anchor link that has with parameter. e.g <a href='' while reading datatable. id should be value of dt.Rows(i)(1). Any advice on this. Thank.

Kyaw Khaung said...

How do you create anchor link that has with parameter. e.g <a href='' while reading datatable. id should be value of dt.Rows(i)(1). Any advice on this. Thank.

Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.