Common Class for masterpages

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?
 
B

bruce barker

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)
 
C

Cowboy \(Gregory A. Beamer\)

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.
 
H

Holy Batman!

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
 
H

Holy Batman!

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).

?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top