Click here to Skip to main content
16,016,562 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
what i want to do is like this:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target

but the html that will be send on iframe will be the HTMLBody of an msg file.


C#
the 2nd html is coming from .msg file

MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\elayronj\Desktop\Sample\sample.msg", Type.Missing);

string body = item.HTMLBody;

<pre lang="text">my problem is, when i get item.HTMLBody and display on the div, its replacing the above html tags.


so the ouput will be like this:
<html>
<body>
<div id="2ndHtml">
(I want to put the other html codes from default.aspx.cs here without replacing the above html codes)
</div>
</body>
</html>


What I have tried:

<html>
<body>
   <div id="mydiv">
      <label>sample</label>
      <button>send</button>
   </div>
   <div id="2ndHtml">
      (I want to put the other html codes from default.aspx.cs here without replacing the above html codes)
   </div>
</body>
</html>
Posted
Updated 17-Feb-16 4:06am
v5
Comments
F-ES Sitecore 16-Feb-16 10:11am    
<div id="2ndHtml">
<p>Hello world</p>
</div>

You'll need to explain your problem a bit better or explain in more detail what you want to do, where the html is coming from etc.
Member 11525563 16-Feb-16 10:45am    
the 2nd html is coming from .msg file

MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\elayronj\Desktop\Sample\sample.msg", Type.Missing);

string body = item.HTMLBody;

my problem is, when i get item.HTMLBody and display on the div, its replacing the above html tags.

so the ouput will be like this:
<html>
<body>
<div id="2ndHtml">
(I want to put the other html codes from default.aspx.cs here without replacing the above html codes)
</div>
</body>
</html>
Suvendu Shekhar Giri 16-Feb-16 10:13am    
Do you want to insert a peice of HTML code in the div, dynamically from the corresponding .cs file?
Member 11525563 16-Feb-16 12:59pm    
Yes.

1 solution

ASP.NET
<div id="mydiv">
    <label>sample</label>
    <button>send</button>
</div>
<div id="2ndHtml">
    <asp:Literal ID="MyHtml" runat="server" />
</div>


code-behind

C#
protected void Page_Load(object sender, EventArgs e)
{
    // the html will come from your msg file
    MyHtml.Text = "<p><strong>Hello World</strong></p>";
}        
 
Share this answer
 
Comments
Member 11525563 16-Feb-16 12:44pm    
still replacing the first tags above it. :(
F-ES Sitecore 17-Feb-16 4:27am    
Is there any javascript in the html you're outputting?
Member 11525563 17-Feb-16 8:12am    
yes, and the button on "mydiv" also has an click event. so i need to place the 2nd html on the 2nd div without replacing the first div.
F-ES Sitecore 17-Feb-16 8:23am    
It could be that the js is doing something to alter the tags then. Try it in a browser with js disabled to see if the tags remain unchanged, and if they do then it's the js that is causing the issue.
Member 11525563 17-Feb-16 8:28am    
already done it without js, but still the html code that i want to put in the 2nd div is still replacing the 1st one

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900