HELP: Setting masterpage at runtime

N

Newbie

Hi,

For my recent web project, I need to built a site which has 3 language. The
content pages are identical, so it only the language that differ. What I
planned is: I'll build a masterpage for each language, and fill up the
content from the database, based on selected language. My question is: is it
possible to determine what masterpage to use at runtime, that is based on
visitors choice of language.

Or, are there any other alternatives/approaches to solve this?

TIA,
Andy
 
K

Karl Seguin [MVP]

The master page can be set during the preInit phase - the event is
specifically put there for this purpose. You can learn more from:
http://odetocode.com/Blogs/scott/archive/2005/12/09/2604.aspx

You might wanna read this 3parter on creatling multilingual pages:
http://openmymind.net/index.aspx?documentId=3
http://openmymind.net/index.aspx?documentId=4
http://openmymind.net/index.aspx?documentId=52

it'll give you some ideas about how to persist user choices and how to
create server controls to make it easier. You can implement your own
ResourceManager (as is done in the article), or not, based on your own
needs, but the other ideas are certainly worth looking at.

Karl
 
M

Matt Dinovo

You can set the masterpage programmatically using the Page.MasterPageFile
property. However, according to MSDN:

The MasterPageFile property is the name of the master page file associated
with this page. The MasterPageFile property can be set only in the PreInit
event; attempting to set the MasterPageFile property after the PreInit event
will throw an InvalidOperationException exception.

HTH,

Matt Dinovo
 
N

Newbie

Hi Karl,

Thanks a lot for the references. Seems a bit complicated, though, but I
think it's just what I need.
I appreciate it.

Regards,
andy

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
 

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

Top