Javascript 将本地html加载到asp.net中的div中
我想将Javascript 将本地html加载到asp.net中的div中,javascript,jquery,html,asp.net,iframe,Javascript,Jquery,Html,Asp.net,Iframe,我想将本地HTML页面加载到asp.net web表单中的一个div中,不需要使用空间解决方案。例如IFRAME,JQUERY.load()等等。 我该怎么做? 注意:此HTML页面从DB加载并上载到web应用程序,因此我不能使用任何URL,如www.foo.com或http://localhost. 一、 我很高兴听到最佳实践或任何想法或解决方案。 谢谢 在表单中添加asp:Literal标记 将HTML标记从DB加载到局部变量 从局部变量初始化asp:Literal标记的Text属性 范例
本地HTML页面
加载到asp.net web表单中的一个div中,不需要使用空间解决方案。例如IFRAME
,JQUERY.load()
等等。我该怎么做?
注意:此HTML页面从DB加载并上载到web应用程序,因此我不能使用任何URL,如
www.foo.com
或http://localhost.
一、 我很高兴听到最佳实践或任何想法或解决方案。谢谢
asp:Literal
标记李>
asp:Literal
标记的Text
属性
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
string html = "<div style='color:red'><b>Hello</b></div>";
// load HTML from DB insead
myHtmlContent.Text = html;
}
受保护的无效页面加载(对象发送方,事件参数e)
{
字符串html=“你好”;
//从DB insead加载HTML
myHtmlContent.Text=html;
}
最后,在一些关于使用哪种解决方案的对话之后,我使用jquery.load()函数进行了操作。当上传我的HTML页面时,用下面的函数调用它
<script>
$(function () {
$("#includedContent").load("../HtmlHolder/index.html");
});
</script>
$(函数(){
$(“#includedContent”).load(“../HtmlHolder/index.html”);
});
并将其放入此HTML标记中:
<div id="includedContent" class="reerer" style="width: 450px; height: 300px; border: 1px solid #808080; margin: 0px auto; overflow-y: scroll;"></div>
它工作得很好
<div id="includedContent" class="reerer" style="width: 450px; height: 300px; border: 1px solid #808080; margin: 0px auto; overflow-y: scroll;"></div>