gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 15:36:13 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com