我如何获得所有可用的 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/