c# 访问所有可用的 css 列表或属性集合

标签 c# .net css class ienumerable

我如何获得所有可用的 Style 属性的列表?

就像在 visual studio 设计器模式中一样,每个支持的元素都有一个 IntelliSense 属性列表, 因此,只要您输入 style=,您就会得到所有可用属性的报价。

我也希望它可以作为代码隐藏的集合或列表使用。 它不应该在公共(public) class 内置的众所周知的 .net 中可用吗?

我正在搜索 System.Web.UI.CssStyleCollection 但无法通过任何方法获取它。我相信它(应该)非常简单。 提前致谢!

msdn 中所述:

指定 HTML 服务器控件的 CssStyleCollection

我试图拥有所有可用的属性,而不仅仅是那些应用于给定页面中的给定元素或控件的属性。 感谢您的评论@Abody97

最佳答案

只找到来源是HtmlTextWriterStyle Enumeration所以要避免使用长名称

HtmlTextWriterStyle.SomeProperty.ToString()

    public sealed class StlProps
    {
       // in visual studio you can just mark the HtmlTextWriterStyle 
       // hit "F12" to its definition to have a list of properties
       // just copy it as const strings 
      public const string BgColor = "BackgroundColor",
                          BackgroundImage = "BackgroundImage",
                          BorderCollapse = "BorderCollapse", 
                          ...etc'

    }

这会让你设置控件样式如下

controlID.Style.Add(stlProps.BgColor, "value from Color Class");

关于c# 访问所有可用的 css 列表或属性集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12759356/

相关文章:

.net - "Invalid postback or callback argument"与数据绑定(bind)控件

c# - ASP.NET Core 1.0 POST IEnumerable<T> 到 Controller

c# - 强类型在 .NET Framework 中意味着什么?

c# - .net 对象大小填充?

c# - 当我使用 StringBuilder.Append 而不是 .AppendLine 时,是否需要添加额外的 .Append(crlf)?

jquery - 自动定位图像

html - 在 <div> 中居中放置 <h1> 标签

c# - 小数点/货币字段的两位小数

c# - jQuery post 数组 - ASP.Net MVC 4

javascript - 站点导航在本地主机上闪烁/闪烁