•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 429,994 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,396 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 452 | Replies: 2
![]() |
•
•
Join Date: Jul 2006
Posts: 46
Reputation:
Rep Power: 3
Solved Threads: 0
Hi,
I have several themes that can be applied to pages on a website based on a users preferences. The problem is that the only way I know how to apply a theme to a website is to set the Page.Theme object in the page's PreInit event. This requires that code be placed on each and every page's PreInit event.
Is there any way to apply a theme globally (as in to all pages in a website) in just one location, such as a master page or the global.asax?
I have several themes that can be applied to pages on a website based on a users preferences. The problem is that the only way I know how to apply a theme to a website is to set the Page.Theme object in the page's PreInit event. This requires that code be placed on each and every page's PreInit event.
Is there any way to apply a theme globally (as in to all pages in a website) in just one location, such as a master page or the global.asax?
•
•
Join Date: Jan 2008
Location: Largo Florida
Posts: 283
Reputation:
Rep Power: 1
Solved Threads: 24
yes you can do it via web.config file as follows :
<configuration> <system.web> <pages theme="yourThemeName" /> </system.web> </configuration>
Serkan Şendur
MCAD.NET
MCAD.NET
•
•
Join Date: Jul 2006
Posts: 46
Reputation:
Rep Power: 3
Solved Threads: 0
The reason that solution would not work for me is that theme must be set based on user preferences stored in some sort of datasource, right now an XML file, and thus would have to be set programmatically (rather than through the web.config file).
The solution I found does the trick. It's code to be placed in the global.asax file, which is exactly where i wanted it to be:
where the theme variable is set to the value retrieved from the XML file
The solution I found does the trick. It's code to be placed in the global.asax file, which is exactly where i wanted it to be:
CSharp Syntax (Toggle Plain Text)
void Application_PreRequestHandlerExecute(object sender, EventArgs e) { Page page = Context.Handler as Page; String theme = "MyTheme"; if (page != null) { page.Theme = theme; } }
where the theme variable is set to the value retrieved from the XML file
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Problem with system architeture
- Next Thread: manipulating text file


Linear Mode