All thanks goes to Almighty Allah !! I have acheived this task by my own mind ...
SQL SCRIPT FOR TABLE :
USE [master]
GO
/****** Object: Database [FontsTesting] Script Date: 8/27/2014 12:46:31 AM ******/
CREATE DATABASE [FontsTesting] ON PRIMARY
( NAME = N'FontsTesting', FILENAME = N'C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\FontsTesting.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'FontsTesting_log', FILENAME = N'C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\FontsTesting_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [FontsTesting] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [FontsTesting].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [FontsTesting] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [FontsTesting] SET ANSI_NULLS OFF
GO
ALTER DATABASE [FontsTesting] SET ANSI_PADDING OFF
GO
ALTER DATABASE [FontsTesting] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [FontsTesting] SET ARITHABORT OFF
GO
ALTER DATABASE [FontsTesting] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [FontsTesting] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [FontsTesting] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [FontsTesting] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [FontsTesting] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [FontsTesting] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [FontsTesting] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [FontsTesting] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [FontsTesting] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [FontsTesting] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [FontsTesting] SET DISABLE_BROKER
GO
ALTER DATABASE [FontsTesting] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [FontsTesting] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [FontsTesting] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [FontsTesting] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [FontsTesting] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [FontsTesting] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [FontsTesting] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [FontsTesting] SET RECOVERY SIMPLE
GO
ALTER DATABASE [FontsTesting] SET MULTI_USER
GO
ALTER DATABASE [FontsTesting] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [FontsTesting] SET DB_CHAINING OFF
GO
USE [FontsTesting]
GO
/****** Object: Table [dbo].[Fonts] Script Date: 8/27/2014 12:46:31 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Fonts](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NULL,
[URL] [nvarchar](50) NULL,
[UserID] [int] NULL,
CONSTRAINT [PK_Fonts] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Fonts] ON
GO
INSERT [dbo].[Fonts] ([ID], [Name], [URL], [UserID]) VALUES (2, N'Tahoma', NULL, 1)
GO
INSERT [dbo].[Fonts] ([ID], [Name], [URL], [UserID]) VALUES (3, N'Lobster', N'http://fonts.googleapis.com/css?family=Lobster', 2)
GO
INSERT [dbo].[Fonts] ([ID], [Name], [URL], [UserID]) VALUES (5, N'Oswald', N'http://fonts.googleapis.com/css?family=Oswald', 3)
GO
SET IDENTITY_INSERT [dbo].[Fonts] OFF
GO
USE [master]
GO
ALTER DATABASE [FontsTesting] SET READ_WRITE
GO
html coding :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link id="styleSheet" rel='stylesheet' type='text/css'/>
</head>
<body runat="server" id="Body">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="FontsCombo" runat="server" Height="31px" Width="127px" >
<asp:ListItem Selected="True">Select Font</asp:ListItem>
<asp:ListItem Value="http://fonts.googleapis.com/css?family=Lobster">Lobster</asp:ListItem>
<asp:ListItem Value="http://fonts.googleapis.com/css?family=Ubuntu">Ubuntu</asp:ListItem>
<asp:ListItem>Arial</asp:ListItem>
</asp:DropDownList>
<br />
<p> I am a body font .... Change me according to session user id</p>
<asp:Button ID="CommitChange" runat="server" Text="Insert New Font"
onclick="CommitChange_Click" />
<br />
</div>
</form>
</body>
</html>
C# Coding :
private string _fontName;
public string StyleSheetUrl;
protected void Page_Load(object sender, EventArgs e)
{
Session["UserID"] = "2";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FontsTestingConnectionString"].ConnectionString);
string command = "SELECT * FROM [dbo].[Fonts] WHERE UserID = '" + Session["UserID"] + "'";
SqlCommand comm = new SqlCommand(command,conn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter{SelectCommand = comm};
DataTable dt = new DataTable();
da.Fill(dt);
foreach (DataRow row in dt.Rows)
{
_fontName = row["Name"].ToString().Trim();
StyleSheetUrl = row["URL"].ToString().Trim();
}
styleSheet.Attributes.Add("href",StyleSheetUrl);
if (_fontName.Trim() == "Lobster")
{
Body.Attributes.Add("style", "font-family:" + _fontName + ";font-size:30px");
}
else
{
Body.Attributes.Add("style", "font-family:" + _fontName + ";");
}
conn.Close();
}
protected void CommitChange_Click(object sender, EventArgs e)
{
if (FontsCombo.SelectedIndex == 0)
{
return;
}
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FontsTestingConnectionString"].ConnectionString);
string command = "INSERT INTO [dbo].[Fonts]([Name],[URL],[UserID]) VALUES(@Name,@Url,@UserID)";
SqlCommand comm = new SqlCommand(command, conn);
comm.Parameters.AddWithValue("@Name", FontsCombo.SelectedItem.Text);
comm.Parameters.AddWithValue("@Url", FontsCombo.SelectedValue);
comm.Parameters.AddWithValue("@UserID", int.Parse(Session["UserID"].ToString()));
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
Response.Write("Record Inserted ");
}
and in web.config :
<connectionStrings>
<add name="FontsTestingConnectionString" connectionString="Data Source=.;Initial Catalog=FontsTesting;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The idea is :
get you favorite fonts from https://www.google.com/fonts , then choose the url given in all fonts like :
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
just copy the href of every desired font and put that in your dropdown's value , and put the name of your font in text of your dropdown .... for e.g in :
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
your dropdown's list item will look like this :
<asp:ListItem Value="http://fonts.googleapis.com/css?family=Lobster">Lobster</asp:ListItem>