Click here to Skip to main content
15,851,902 members
Please Sign up or sign in to vote.
1.82/5 (3 votes)
See more:
Hi,

i have two css plugin let say test1.css and test2.css

I am getting value from database as 1 or 2

if the value is 1 i want test1.css plugin should be used for the application and if 2 then test2.css should be use

for eg
<head id="Head1" runat="server">

if(val==1)
{
<link href="CSS/test1.css" rel="stylesheet" />

}

else

{
<link href="CSS/test2.css" rel="stylesheet" />

}

</head>
Posted

1 solution

hi, you can do it like this,

//client side
ASP.NET
<head id="Head1" runat="server">
<link rel="stylesheet" type="text/css" id="idStyle" runat="server" /> <!-- add id and runat="server" -->
</head>


//server side

C#
protected void Page_Load(object sender, EventArgs e)
{
    if(yourcondition)
    {
         idStyle.Attributes.Add("href", "CSS/test1.css");
    }
    else
    {
         idStyle.Attributes.Add("href", "CSS/test2.css");
    }
}



hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900