Question

I have two master pages in my project, one for web views and another for emails. In the web master page is a placeholder to put page specific JavaScript, if a page is using this and I try to programmatically change the masterpage to send as an email the server falls over as it can't find the placeholder.

Is there a way to change the behaviour so that if a placeholder can't be found it just doesn't include that bit? I'm thinking maybe on my page base class looping over a collection of placeholders and content tags and removing the ones that don't match up, but I'm not sure if there's a good point in the page lifecycle to do this.

I'm using MVC not WebForms if this makes a difference.

Was it helpful?

Solution

Add the ContentPlaceHolder into the mail masterpage and set the visible property to false and the content from the page for that placeholder won't render.

<asp:ContentPlaceHolder id="javascriptPlaceHoldereHolder1" runat="server" Visible="false" />

OTHER TIPS

You can't have a Content control with a ContentPlaceHolderID that doesn't exist.

Instead of taking the ContentPlaceHolder out, why don't you just provide an empty Content control? It'll just render nothing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top