Programmatically Creating Themes and Skins

  • Thread starter Thread starter Cramer
  • Start date Start date
C

Cramer

According to the MSDN docs, we cannot programatically create our own themes
or skins:
"Page and control developers do not use the ControlSkinDelegate,
ControlSkin, or PageTheme classes directly. These classes are used by the
ASP.NET parser and runtime ... " (from
http://msdn.microsoft.com/en-us/library/system.web.ui.pagetheme.aspx).

My question:
Is there really no way that we can programmatically create our own themes
and have ASP.NET apply them to our pages and controls? I would like to
programmatically create my own themse, and not have to go with the expected
App_Themes directory for all of my themes. Is there some alternative I can
use?

Thanks
 
According to the MSDN docs, we cannot programatically create our own themes
or skins:
"Page and control developers do not use the ControlSkinDelegate,
ControlSkin, or PageTheme classes directly. These classes are used by the
ASP.NET parser and runtime ... " (fromhttp://msdn.microsoft.com/en-us/library/system.web.ui.pagetheme.aspx).

My question:
Is there really no way that we can programmatically create our own themes
and have ASP.NET apply them to our pages and controls? I would like to
programmatically create my own themse, and not have to go with the expected
App_Themes directory for all of my themes. Is there some alternative I can
use?

Thanks

You can change the allocation of themes to controls programatically
just as you can dynamically associate CSS classes and styles. However
the dynamic creation of new style sheets and skin files is outside
their designed purpose. The location of the theme files is fixed
because that is where ASP.NET has been hard coded to expect them (or
maybe set in machine.config).

I'm not suggesting that this can't be circumvented in some way but I
wonder whether it's worth the effort. If there is a need to vary style
attributes at run time based on some computed criteria, then it
doesn't have to come from style sheets or skin files. It could be
derived from re-useable code of your own creation (e.g. in a class
file) consisting of functions returning style objects or other control
properties either based on the values supplied as parameters or on a
different function for each theme. It requires a bit of ingenuity but
at least the end result will be more system friendly and supportable.
 
Back
Top