如何以编程方式检索 HTML 服务器控件的样式?

发布于 2024-12-17 08:35:04 字数 215 浏览 3 评论 0原文

假设我有

;标签 id="toggleText" & runat="Server" 然后我可以使用以下命令更改样式属性 -

toggleText.Style.Add("Display", "block");

但如果我想检索样式属性那么该怎么做?

谢谢

Suppose i'm having <div> tag with id="toggleText" & runat="Server" then i can change style attributes by using following -

toggleText.Style.Add("Display", "block");

But if i want to retrieve the style attribute then how to do this?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅紫色的梦幻 2024-12-24 08:35:04

简单的:

 toggleText.Style["Display"];

Easy:

 toggleText.Style["Display"];
喜你已久 2024-12-24 08:35:04

When you query the control's Style property you get "a collection of all cascading style sheet (CSS) properties applied to a specified HTML server control in the ASP.NET file" - there's a code sample on that page as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文