ASP.NET 2.0 - Can I easily control the master page from the Profil

G

Guest

I want to allow users to choose the look of my site. I am controlling the
look using master pages. I have 2 master pages to choose from. I want to
store and control the user's choice using the Profile stuff in 2.0. I can do
it by setting the master page in the code of each page to a value in the
Profile, but I was wondering if there is something simpler built in that I am
missing. Thanks.
 
S

Scott Allen

You could derive all of your pages from a base class, which can use
the PreInit event to set the master page.
 
N

neilmcguigan

Create a class file like this:

namespace WebApplication4 //or whatever
{
public class MyPage : System.Web.UI.Page
{
public string name = "neil";
}
}

your web.config should have a <pages> section like this:

<configuration>
<system.web>
<pages pageBaseType="WebApplication4.MyPage,WebApplication4" />
</system.web>
</configuration>

this is for non code behind

in your codebehind pages, you'd change this:

public class WebForm2 : System.Web.UI.Page
{
....
}

to this


public class WebForm2 : WebApplication4.MyPage
{
....
}

cheers
 

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
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top