如何在服务器上设置css (后台)属性?暂时不起作用:(
政务司司长
public string MyBackgroundColor { get; set; }aspx
<style type="text/css">
html
{
background-color: '<%=MyBackgroundColor %>';
}
</style>发布于 2012-02-02 09:41:00
你可以试试
.aspx
<body id="body" runat="server">
...the body.aspx.cs
body.Style["Background-Color"] = blue;//just example you can try using your method too发布于 2012-02-02 14:09:22
你可以这样做
Page.Header.Controls.Add(
new LiteralControl(
@"<style type='text/css'>
html
{
background-color: red;
}
</style>
"
)
);发布于 2012-02-02 11:00:56
假设您的样式标记在<head>元素中,将=更改为# (background-color: '<%#MyBackgroundColor %>';),向<head>元素添加一个runat="server",并在Page_Load事件中调用Page.Header.DataBind()。
https://stackoverflow.com/questions/9105895
复制相似问题