简体   繁体   中英

c# access to all available css list or collection of properties

how can i get a list of all Style properties available ?

like in the visual studio desingner mode there's an IntelliSense properties list for each element supported, so as soon as you type style= you get offerd by all available properties.

i would like to have it available as a collection or list in code behind too. shouldn't it be available in a well known .net built in public class ?

i was searching the System.Web.UI.CssStyleCollection but couldn't get it through any method yet. i am sure it is (should be) very simple . thanks in advance !

as explained in msdn :

CssStyleCollection for the specified HTML server control

i was trying to have all available properties not only those applied on a given element or control in a given page. thanks for your comment @Abody97

found only source to be HtmlTextWriterStyle Enumeration so to avoid use of long name

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'

    }

this will let you set control style as follows

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM