Common Class for masterpages

  • Thread starter Thread starter Holy Batman!
  • Start date Start date
H

Holy Batman!

This is a bit of a beginner question because I'm a bit of a beginner.

I've created several masterpages and I'm not sure which I like best.
So I've created a couple linkbuttons that let the user switch between
masterpages and save that info into a cookie. This is read in the
page_preinit and the appropriate page is loaded.

Currently, I have logic in the codebehind of each masterpage doing the
same thing (e.g. setting the cookie for the choice of masterpage,
logging choice of masterpage, setting navigateUrl for some links,
other various and sundry items).

How do I consolidate that code and make it accessible to all the
masterpages?
 
use oop. create a new class that inherits from MasterPage, and have your
master pages inherit from you new class rather than MasterPage

-- bruce (sqlwork.com)
 
Create a class file that inherits from the master page base class. You can
then put the common code in this class.

Then Change the code behind for the master to point to this new "page".

If you are simply using different masters to change looks, you should use
themes instead. You can use the exact same master, with different CSS, etc.,
to theme a page rather nicely and avoid having to have multiple "pages"
inherit from a class with common code. Just my two cents.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
 
Ha! In other words, exactly the same thing that I'm doing with my
regular pages so that I can have the pre-init logic choose the
masterpage.
:)

Funny how the beginner brain works (or doesn't).
Thanks
Brian
 
Thanks for the class advice.

Perhaps you can clarify for me, I was under the impression that themes
were not much different than a css swapping mechanism. That would
work for me except that I've been altering the underlying html a bit
(a few extra hooks for rounded corners and so on).

?
 
Back
Top