2016-04-24 63 views
-1

我想将LOCAL HTML PAGE加载到asp.net web表单中的div中,并且不需要使用空间解决方案,例如IFRAME,JQUERY.LOAD()等等。
我该怎么做?
注:从DB这个HTML页面加载,并上传到Web应用程序,所以我不能使用任何URL如www.foo.comhttp://localhost. 我,很高兴听到最佳做法或任何想法或解决方案。
谢谢。在asp.net中将本地html加载到div中

回答

0

最后经过一些谈话以使用哪种解决方案,我用jquery.load()函数来做到这一点。
上传我的HTML页面时,用下面的函数调用它。

<script> 
     $(function() { 
      $("#includedContent").load("../HtmlHolder/index.html"); 
     }); 

    </script> 

,并把它放在这个HTML标签:

<div id="includedContent" class="reerer" style="width: 450px; height: 300px; border: 1px solid #808080; margin: 0px auto; overflow-y: scroll;"></div> 

它工作得很好。

0
  1. asp:Literal标记添加到您的表单;
  2. 加载从DB你的HTML标记一个局部变量
  3. 从局部变量

表初始化asp:Literal标签的Text属性:

<asp:Literal ID="myHtmlContent" runat="server"></asp:Literal> 

后面的代码:

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; 
    }