2016-04-24 65 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; 
    }