![]() |
|
|
|
#1 |
|
Greetings,
So, I now have a custom IHttpModule class that I use to establish the Theme for each page, based on the user's settings. Seems to work just fine. Thanks to everyone who made helpful suggestions. The code I copied looked something like the listing below. In the Init method, it sets a handler for PreRequestHandlerExecute. And then in the PreRequestHandlerExecute method, it sets a handler for the page's PreInit. The result is that I have a global handler for every pages' PreInit. But now I'm wondering if this many layers is required. Is there any reason to not simply set the page's theme in the PreRequestHandlerExecute method, and eliminate the PreInit handler? It even seems like all my session and membership data is available during PreRequestHandlerExecute (although some of my database data is cached in the Session object). How would I determine if I need the PreInit handler? Thanks. public class ThemeManager : IHttpModule { public ThemeManager() { } public void Init(HttpApplication app) { app.PreRequestHandlerExecute += new EventHandler(Context_PreRequestHandlerExecute); } void Context_PreRequestHandlerExecute(object sender, EventArgs e) { Page page = HttpContext.Current.CurrentHandler as Page; if (page != null) page.PreInit += new EventHandler(Page_PreInit); } void Page_PreInit(object sender, EventArgs e) { Page page = (Page)sender; // Set page theme here! } public void Dispose() { } } Jonathan Jonathan Wood |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 70-536 questions and time limit for exam? type of questions? | gravz84 | MCTS | 2 | 11-22-2007 07:57 PM |
| 70-536 questions and time limit for exam? type of questions? | gravz84 | MCTS | 0 | 11-13-2007 05:44 PM |
| 70-536 Details | Gary Gallagher | MCTS | 10 | 06-30-2007 01:08 PM |
| Re: A+ Test Questions | jsaulinskas@sbcglobal.net | A+ Certification | 0 | 01-20-2005 03:19 AM |
| A+ Exam | Anthony Coletta | A+ Certification | 5 | 05-07-2004 10:07 PM |