如何将html代码放入我的div中? [英] How do i put html codes inside my div?

查看:214
本文介绍了如何将html代码放入我的div中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是这样的:

http:// www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target



但是将在iframe上发送的html将是HTMLBody msg文件。





第二个html 来自来自 .msg文件

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

string body = item.HTMLBody;

< pre lang = text>我的问题 i get item.HTMLBody and display在div上,它取代了上面的html标签。





所以输出将是这样的:

< HTML> 
< body>
< div id =2ndHtml>
(我想把default.aspx.cs中的其他html代码放在这里而不替换上面的html代码)
< / div>
< / body>
< / html>





我尝试过:



< html> 
< body>
< div id =mydiv>
< label>样本< / label>
< button>发送< / button>
< / div>
< div id =2ndHtml>
(我想把default.aspx.cs中的其他html代码放在这里而不替换上面的html代码)
< / div>
< / body>
< / html>

解决方案

 <   div     id   =  mydiv >  
< label > sample < / label >
< 按钮 > 发​​送< / button >
< / div >
< div id = 2ndHtml >
< asp: Literal ID = MyHtml runat = server / >
< / div >





代码隐藏



protected void Page_Load( object sender,EventArgs e)
{
// html将来自你的msg文件
MyHtml.Text = < p>< strong> Hello World< /强>< / p>中;
}


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.


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>

解决方案

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



code-behind

protected void Page_Load(object sender, EventArgs e)
{
    // the html will come from your msg file
    MyHtml.Text = "<p><strong>Hello World</strong></p>";
}        


这篇关于如何将html代码放入我的div中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆