How to define, at run-time, the master to be used by a page?

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I have realy two websites in one host folder.

To get to one use Default1.aspx to get to the other use Default2.aspx.

Default1 and all the pages that it's menu goes to uses One.master.
Default2 and all the pages that it's menu goes to uses Two.master.

However, there are some pages that should be available from both sites.

So the question is: can I somehow define, at run-time, the master to be used
by a page.

That is, if a page is opened from Default1 I want it to use One.master, and
if it is accessed from Default2 I want it to use Two.master.

Can you tell me how to do that?

Or some other approach?


Thanks in advance
 
I have realy two websites in one host folder.

To get to one use Default1.aspx to get to the other use Default2.aspx.

Default1 and all the pages that it's menu goes to uses One.master.
Default2 and all the pages that it's menu goes to uses Two.master.

However, there are some pages that should be available from both sites.

So the question is: can I somehow define, at run-time, the master to be used
by a page.

That is, if a page is opened from Default1 I  want it to use One.master, and
if it is accessed from Default2 I want it to use Two.master.

Can you tell me how to do that?

Or some other approach?

Thanks in advance

How many master pages do you have? If there is only one, I would
recommend to copy it between projects. You can set the master
programmatically using the page's PreInit event. But in this case you
would need to refer also to other project (dlls) and this could be a
problem I guess.
 
I have realy two websites in one host folder.

To get to one use Default1.aspx to get to the other use Default2.aspx.

Default1 and all the pages that it's menu goes to uses One.master.
Default2 and all the pages that it's menu goes to uses Two.master.

However, there are some pages that should be available from both sites.

So the question is: can I somehow define, at run-time, the master to be
used
by a page.

That is, if a page is opened from Default1 I want it to use One.master,
and
if it is accessed from Default2 I want it to use Two.master.

Can you tell me how to do that?

Or some other approach?

Thanks in advance

How many master pages do you have? If there is only one, I would
recommend to copy it between projects. You can set the master
programmatically using the page's PreInit event. But in this case you
would need to refer also to other project (dlls) and this could be a
problem I guess.





Two master pages and I'll try to select the active one in PreInit of the
aspx.vb file by using a Session variable.



Thanks
 
Mark Rae said:

I thought the idea was so unusual that probably no one had considered it.
Never occurred to me that there would be info on the Internet.

I'm going to leave one in the @Page directive and when appropriate select
the other master in PreInit (using a Session variable to indicate whether I
should use the one in the @Page or select the other one.).

Thanks
 
Mark Rae said:
I do this all the time:
http://www.sanctuaryrig.co.uk/home/default.aspx
http://www.inthecage.co.uk/home/default.aspx
http://www.jimfaupel.co.uk/home/default.aspx
http://www.manirdonaghue.co.uk/home/default.aspx

Click the "Log in" button or hyperlink in each of the four websites - same
website in each case (see the URL in the address bar), but with different
MasterPages...
I realize now it is not so unusual.

The sites are interesting. One thing I noticed is that you use the e-mail
address as the login username.

I use asp:CreateUserWizard and couldn't manage to do that. It's been a while
but I think the problem I had was that that method actually stores a
username and a e-mail address separately and I was having a problem keeping
them synchronized. Do you make the user type it in as a username and also as
an e-mail address and then check to see if they are the same?


Thanks
 
I realize now it is not so unusual.

Indeed not. Tom Jones was right... ;-)

The sites are interesting. One thing I noticed is that you use the e-mail
address as the login username.

That's correct. It's by far the simplest piece of information about a person
which is guaranteed to be unique...

I use asp:CreateUserWizard

I don't...

Do you make the user type it in as a username and also as an e-mail
address

No.
 
Mark Rae said:
Indeed not. Tom Jones was right... ;-)



That's correct. It's by far the simplest piece of information about a
person which is guaranteed to be unique...



I don't...



No.

That is what I expected

thanks
 
Do you create a base master page and derive your masters from it so that you
can use

<%@ MasterType TypeName="BaseMaster" %>
Or is there a way with a smaller footprint?Thanks
 
Do you create a base master page and derive your masters from it so that
you can use

<%@ MasterType TypeName="BaseMaster" %>

I certainly do.

Each of the links mentioned a couple of replies ago contains an encrypted
querystring which is used to determine which MasterPage to use - if you were
to try to access http://www.markraesecure.com with an unrecognised
name/value pair in the querystring, or no querystring at all, you'd just be
redirected to my main business website. The querystring is decrypted and a
Site object is then stored in a Session variable - this determines which
MasterPage and CSS to use. Next, the login page is displayed and, assuming
login is successful, a User object is stored in a Session variable, and off
we go from there...

Or is there a way with a smaller footprint?

Smaller footprint...???
 
Back
Top