Reputation: 2203
I have a master page and a content page. Content page content is dynamic and is HTML(html Mail). Content is fetched from DB and displayed dynamically. This is how the page looks like on "View Source".
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="mailBody" runat="server" style="overflow: auto; width: 600px; height: 500px;">
<!-- Dynamic Content Starts from here-->
<html>
<head>
<style>
</style>
</head>
<body>
<!--Body goes here-->
</body>
</html>
<!-- Dynamic Content Ends here-->
</div>
</asp:Content>
And I'm adding dynamic content data like this.
mailBody.InnerHtml = mail;
My problem is, dynamic content has its own style and it is getting copied by the master page and is messing up my Master page style, background, font etc. I want content page to be in its own stye without affecting master page. How to achieve this?
Upvotes: 0
Views: 244
Reputation: 1320
If the html, style and body tags are part of the content stored in the database (a complete html page), I think you'll have to use an iframe. That means you would have some separate file like mailbody.asp that renders your dynamic content. Then you would call it from your master page in an iframe like so
<iframe src="mailbody.asp"></iframe>
Upvotes: 1
Reputation: 1698
I suggest that put your content page content into a div
, for example, and assign page style to it. Then set innerHtml
for mailBody
container:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="pageStyle">
<div class='yourDynamicClass' id="mailBody" runat="server" >
</div>
</div>
</asp:Content>
and define classes or id's in a .css file.
Also, you can use some html tags for innerHtml:
mailBody.InnerHtml = "<div class='className'>" + mail + "</div>"
Upvotes: 1