Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Anyone Setting Themes from Master Page

 
Thread Tools Search this Thread
Old 06-02-2008, 09:07 PM   #1
Default Anyone Setting Themes from Master Page


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
  Reply With Quote
Old 06-02-2008, 09:15 PM   #2
Rain
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-02-2008, 10:06 PM   #3
David Wier
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-02-2008, 10:22 PM   #4
Juan T. Llibre
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-03-2008, 12:08 AM   #5
Jonathan Wood
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-03-2008, 12:09 AM   #6
Jonathan Wood
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-03-2008, 12:11 AM   #7
Jonathan Wood
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-03-2008, 03:52 PM   #8
clintonG
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Old 06-03-2008, 05:34 PM   #9
Jonathan Wood
 
Posts: n/a
Default Re: Anyone Setting Themes from Master Page
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46