[英]c# access to all available css list or collection of properties
如何获得所有可用的Style
属性的列表?
就像在Visual Studio desingner模式下一样,每个支持的元素都有一个IntelliSense属性列表,因此,一旦键入style=
您就会获得所有可用属性的提示。
我也想将其作为集合或在后面的代码中列出。 它不应该在公共class
内置的.net中可用吗?
我正在搜索System.Web.UI.CssStyleCollection
但无法通过任何方法获取它。 我确信这(应该)非常简单。 提前致谢 !
如msdn中所述 :
指定 HTML服务器控件的CssStyleCollection
我试图拥有所有可用属性,而不仅仅是那些应用于给定页面中给定元素或控件的属性。 感谢您的评论@ Abody97
发现唯一的源是HtmlTextWriterStyle枚举,因此避免使用长名称
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.