![]() |
|
|
|||||||
![]() |
ASP Net - Anyone Setting Themes from Master Page |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
I want to dynamically set my site's theme based on a setting stored in my
database. I just hooked this up but get an error that the theme can only be set in the page's PreInit event or earlier. However, it appears that Master pages do not have PreInit events. I REALLY do not want to have to stick the same code in each and every page I create. How are you folks dynamically setting themes from master pages? Thanks. Jonathan Jonathan Wood |
|
|
|
|
#2 |
|
Posts: n/a
|
You could make every page inherit from a base class with the code you want
in the pre init event. "Jonathan Wood" <> wrote in message news:ej%... >I want to dynamically set my site's theme based on a setting stored in my >database. > > I just hooked this up but get an error that the theme can only be set in > the page's PreInit event or earlier. However, it appears that Master pages > do not have PreInit events. > > I REALLY do not want to have to stick the same code in each and every page > I create. How are you folks dynamically setting themes from master pages? > > Thanks. > > Jonathan > Rain |
|
|
|
#3 |
|
Posts: n/a
|
Why don't you just set it in the web.config, for the whole site?
David Wier http://aspnet101.com http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no bloated markup "Jonathan Wood" <> wrote in message news:ej%... >I want to dynamically set my site's theme based on a setting stored in my >database. > > I just hooked this up but get an error that the theme can only be set in > the page's PreInit event or earlier. However, it appears that Master pages > do not have PreInit events. > > I REALLY do not want to have to stick the same code in each and every page > I create. How are you folks dynamically setting themes from master pages? > > Thanks. > > Jonathan > David Wier |
|
|
|
#4 |
|
Posts: n/a
|
Check out K. Scott Allen's great articles with good sample code :
http://odetocode.com/Blogs/scott/arc...2/09/2604.aspx http://www.odetocode.com/Articles/450.aspx Rick Strahl has an alternate method : http://www.west-wind.com/WebLog/posts/4899.aspx Also, you could set the global theme in web.config: <configuration> <system.web> <pages theme="ThemeName" /> </system.web> </configuration> Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Jonathan Wood" <> wrote in message news:ej%... >I want to dynamically set my site's theme based on a setting stored in my database. > > I just hooked this up but get an error that the theme can only be set in the page's PreInit event or earlier. However, > it appears that Master pages do not have PreInit events. > > I REALLY do not want to have to stick the same code in each and every page I create. How are you folks dynamically > setting themes from master pages? > > Thanks. > > Jonathan > Juan T. Llibre |
|
|
|
#5 |
|
Posts: n/a
|
Because that won't help me change it dynamically.
-- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com "David Wier" <> wrote in message news:... > Why don't you just set it in the web.config, for the whole site? > > David Wier > http://aspnet101.com > http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with > no bloated markup > > > "Jonathan Wood" <> wrote in message > news:ej%... >>I want to dynamically set my site's theme based on a setting stored in my >>database. >> >> I just hooked this up but get an error that the theme can only be set in >> the page's PreInit event or earlier. However, it appears that Master >> pages do not have PreInit events. >> >> I REALLY do not want to have to stick the same code in each and every >> page I create. How are you folks dynamically setting themes from master >> pages? >> >> Thanks. >> >> Jonathan >> > > Jonathan Wood |
|
|
|
#6 |
|
Posts: n/a
|
It's a reasonable suggestion, but would still require that I go back and
modify each and every page created so far. I'll leave this as second choice but am looking into more of a global handler approach if possible. Jonathan "Rain" <> wrote in message news:... > You could make every page inherit from a base class with the code you want > in the pre init event. > > > "Jonathan Wood" <> wrote in message > news:ej%... >>I want to dynamically set my site's theme based on a setting stored in my >>database. >> >> I just hooked this up but get an error that the theme can only be set in >> the page's PreInit event or earlier. However, it appears that Master >> pages do not have PreInit events. >> >> I REALLY do not want to have to stick the same code in each and every >> page I create. How are you folks dynamically setting themes from master >> pages? >> >> Thanks. >> >> Jonathan >> > > Jonathan Wood |
|
|
|
#7 |
|
Posts: n/a
|
Juan,
> Check out K. Scott Allen's great articles with good sample code : > > http://odetocode.com/Blogs/scott/arc...2/09/2604.aspx > http://www.odetocode.com/Articles/450.aspx > > Rick Strahl has an alternate method : > http://www.west-wind.com/WebLog/posts/4899.aspx Thanks, these look like good references. > Also, you could set the global theme in web.config: > > <configuration> > <system.web> > <pages theme="ThemeName" /> > </system.web> > </configuration> I'm doing this now. But this doesn't help me change it dynamically. Jonathan Jonathan Wood |
|
|
|
#8 |
|
Posts: n/a
|
There is no work-around in this context Jonathan. We MUST use a base class
that each page inherits from. "Jonathan Wood" <> wrote in message news:... > It's a reasonable suggestion, but would still require that I go back and > modify each and every page created so far. I'll leave this as second > choice but am looking into more of a global handler approach if possible. > > Jonathan > > "Rain" <> wrote in message > news:... >> You could make every page inherit from a base class with the code you >> want in the pre init event. >> >> >> "Jonathan Wood" <> wrote in message >> news:ej%... >>>I want to dynamically set my site's theme based on a setting stored in my >>>database. >>> >>> I just hooked this up but get an error that the theme can only be set in >>> the page's PreInit event or earlier. However, it appears that Master >>> pages do not have PreInit events. >>> >>> I REALLY do not want to have to stick the same code in each and every >>> page I create. How are you folks dynamically setting themes from master >>> pages? >>> >>> Thanks. >>> >>> Jonathan >>> >> >> > clintonG |
|
|
|
#9 |
|
Posts: n/a
|
Actually... that's not quite true. In fact, I was able to implement my own
IHttpModule class that handles themes for all pages globally, without needing to modify each page. Jonathan "clintonG" <> wrote in message news:... > There is no work-around in this context Jonathan. We MUST use a base class > that each page inherits from. > > > "Jonathan Wood" <> wrote in message > news:... >> It's a reasonable suggestion, but would still require that I go back and >> modify each and every page created so far. I'll leave this as second >> choice but am looking into more of a global handler approach if possible. >> >> Jonathan >> >> "Rain" <> wrote in message >> news:... >>> You could make every page inherit from a base class with the code you >>> want in the pre init event. >>> >>> >>> "Jonathan Wood" <> wrote in message >>> news:ej%... >>>>I want to dynamically set my site's theme based on a setting stored in >>>>my database. >>>> >>>> I just hooked this up but get an error that the theme can only be set >>>> in the page's PreInit event or earlier. However, it appears that Master >>>> pages do not have PreInit events. >>>> >>>> I REALLY do not want to have to stick the same code in each and every >>>> page I create. How are you folks dynamically setting themes from master >>>> pages? >>>> >>>> Thanks. >>>> >>>> Jonathan >>>> >>> >>> >> > Jonathan Wood |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Digital Album Master - Make High Resolution Slideshow For TV | jerryliang | Software | 0 | 07-17-2009 03:16 AM |
| master page & app_theme folder doesn't work | dummies2 | General Help Related Topics | 0 | 09-04-2007 05:41 PM |
| Classic Original Broadcasts Trading List - Updated ( w/o/c ) | porkys1982@sbcglobal.net | DVD Video | 0 | 12-05-2005 03:38 AM |
| Classic Original Broadcasts Trading List - Updated ( w/o/c ) | porkys1982@sbcglobal.net | DVD Video | 0 | 11-19-2005 04:46 PM |
| Original Airings : The A-Team , M*A*S*H , Taxi , Barney Miller , WKRP | porkys1982@sbcglobal.net | DVD Video | 0 | 08-15-2005 03:09 AM |