在asp.net中动态添加删除css插件 [英] Add remove css plugin dynamically in asp.net
本文介绍了在asp.net中动态添加删除css插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有两个css插件让我们说test1.css和test2.css
我从数据库中获得的价值为1或2
如果值为1我想要test1.css插件应该用于应用程序,如果2则那么test2.css应该使用
例如
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)
{
if(val==1)
{
<link href="CSS/test1.css" rel="stylesheet" />
}
{
}
else
{
<link href="CSS/test2.css" rel="stylesheet" />
}
}
</head>
推荐答案
你可以这样做,
//客户端
you can do it like this,
//client side
<head id="Head1" runat="server">
<link rel="stylesheet" type="text/css" id="idStyle" runat="server" /> <!-- add id and runat="server" -->
</head>
//服务器端
//server side
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.
这篇关于在asp.net中动态添加删除css插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文