PC Review


Reply
Thread Tools Rate Thread

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

 
 
Cal Who
Guest
Posts: n/a
 
      17th May 2010
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



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      17th May 2010
On May 17, 5:27*pm, " Cal Who" <CalWhoNOS...@roadrunner.com> wrote:
> 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.
 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      17th May 2010
" Cal Who" <(E-Mail Removed)> wrote in message
news:hsrn8r$o9r$(E-Mail Removed)...

> Can you tell me how to do that?


http://tinyurl.com/2dzgsk7


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      17th May 2010

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:d700aef4-1f3b-445f-887a-(E-Mail Removed)...
On May 17, 5:27 pm, " Cal Who" <CalWhoNOS...@roadrunner.com> wrote:
> 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



 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      17th May 2010

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>" Cal Who" <(E-Mail Removed)> wrote in message
>news:hsrn8r$o9r$(E-Mail Removed)...
>
>> Can you tell me how to do that?

>
> http://tinyurl.com/2dzgsk7
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


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


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      17th May 2010
" Cal Who" <(E-Mail Removed)> wrote in message
news:hss3pl$3nm$(E-Mail Removed)...

> I thought the idea was so unusual that probably no one had considered it.


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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      19th May 2010

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>" Cal Who" <(E-Mail Removed)> wrote in message
>news:hss3pl$3nm$(E-Mail Removed)...
>
>> I thought the idea was so unusual that probably no one had considered it.

>
> 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...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net

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


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      19th May 2010
" Cal Who" <(E-Mail Removed)> wrote in message
news:hsvbcc$1db$(E-Mail Removed)...

> 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
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      19th May 2010

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:5912587F-DF6E-4DE4-9C71-(E-Mail Removed)...
>" Cal Who" <(E-Mail Removed)> wrote in message
>news:hsvbcc$1db$(E-Mail Removed)...
>
>> 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
> ASP.NET MVP
> http://www.markrae.net


That is what I expected

thanks


 
Reply With Quote
 
Cal Who
Guest
Posts: n/a
 
      19th May 2010

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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
modify master page from sub page in run time =?Utf-8?B?Tmljaw==?= Microsoft ASP .NET 3 12th Nov 2006 07:56 AM
How to add menu to a master page at run time? tomix Microsoft ASP .NET 1 29th Oct 2006 09:36 AM
define keyboard shortcut to in/de-crease master volume =?Utf-8?B?dWxyaWNo?= Windows XP General 1 21st Feb 2006 07:04 PM
? define Master Catagories list on a public contacts on exchnge se =?Utf-8?B?QmFua0J1c3Rlcg==?= Microsoft Outlook Contacts 0 15th Sep 2005 05:55 PM
How to define primary key in Master-Detail Table. Agnes Microsoft VB .NET 0 8th Dec 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:00 PM.