如何在ASP.NET中的div的文件背后的代码中修改CSS样式? [英] How do you modify a CSS style in the code behind file for divs in ASP.NET?

查看:82
本文介绍了如何在ASP.NET中的div的文件背后的代码中修改CSS样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据从aspx页面后面的代码中从数据库表获得的信息来修改div的CSS样式属性.以下本质上是我要尝试执行的操作,但出现错误.

I'm trying to modify a CSS style attribute for a div based on the information I get from a database table in the code behind of my aspx page. The following is essentially what I am trying to do, but I get errors.

Aspx:

<div id="testSpace" runat="server">
    Test
</div>

后面的代码:

testSpace.Style = "display:none;"    
testSpace.Style("display") = "none";

我在做什么错了?

推荐答案

testSpace.Style.Add("display", "none");

这篇关于如何在ASP.NET中的div的文件背后的代码中修改CSS样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆