Developer forum

Forum » CMS - Standard features » Conditional rendering of Master page files

Conditional rendering of Master page files

Snævar Dagur Pétursson
Reply

Hi.
I was wondering if it is possible to conditionaly render a MasterPageFile reference in DW.
This is what I am looking to do.

@{

    string ajaxRequest = System.Web.HttpContext.Current.Request.QueryString["ajax"];

}

 

@if (ajaxRequest == "true"){

    @MasterPageFile("Master/Empty.cshtml")

}

else{

    @MasterPageFile("Master/MasterPage.cshtml")

}

But in this case both master templates are rendered.

Best Regards,
Snævar 


Replies

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply
This post has been marked as an answer

Hi Snævar,

I believe it's not possible. But you can change the page layout template using the querystring parameter: LayoutTemplate=Designs/YOURDESIGNFOLDER/yourfilepath.cshtml.
I usually have a clean layout template for the ajax calls just with the DW container.

Hope this helps,
BR, Mário

 

Votes for this answer: 2
 
Snævar Dagur Pétursson
Reply

Thanks Mario! That did the trick smiley

 

 

You must be logged in to post in the forum