Developer forum

Forum » Development » Change layout file on the fly through code

Change layout file on the fly through code

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Hi there,

Is there a way to change the layout file on the fly through code? I have a custom module that has a List and a Details view. For each I would like to use a different Layout file which I need to assign dynamically. I don't necessarily have to do it from my custom  module, anywhere in Global.asax or Default.apsx is fine as well.

Can this be done?
 

Imar


Replies

 
Nicolai Høeg Pedersen
Reply
Subscribe to Notifications.Standard.Page.Loaded

Set the template like this:
Dynamicweb.Frontend.PageView.Current.Page.Value("PageLayout") = "Designs/Dynamicweb/MainAlt.html"

You can also add a querystring parameter: &LayoutTemplate=Designs/Dynamicweb/MainAlt.html
 
Nicolai Høeg Pedersen
Reply
Oh - does not work... The notification is raised too late... Will look further.
 
Nicolai Høeg Pedersen
Reply
I've moved around in the code so the example with the notification will work after next service release.
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Cool again. And thanks again!

Imar

 

You must be logged in to post in the forum