2013-10-29 16 views
0

我有一個場景,當任何請求失敗時,我需要導航到我自己的自定義html頁面。我面臨的問題是我有一個背景圖片,我需要顯示自定義html頁面。將背景圖像加載到Web瀏覽器控件中的自定義Html頁面

我已經實現的代碼如下:

CustomHtmlDoc = "<html><head></head><body background=\"{0}\"; oncontextmenu='return false;'><br><br></br></br><hr><h4 style='font-family:Footlight MT Light;color:red;font-size:20px;'>" + "ErrorMessage" + "</h4><h4 style='font-family:Footlight MT Light;color:red;font-size:25px;'>Please Verify the Configured URL from Dashboard Configuration</h4> <hr></body></html>"; 
string CustomHtmlDocument = string.Format(CustomHtmlDoc,AppDomain.CurrentDomain.BaseDirectory + "AdministrationUIBrowser\\AdministrationUIBrowserFactory\\ErrorBackground.png"); 
WebBrowserControlView.DocumentText = CustomHtmlDocument; 

我能夠得到的錯誤頁面爲背景,當我嘗試在本地運行的方案。但是在部署結束時,我只是在沒有任何背景圖像的情況下獲得了空白屏幕。我的是一個WPF應用程序。

+0

什麼是實際的'CustomHtmlDocument'內容的情況下,它不起作用。例如,這工作:\t \t \t'this.webBrowser.DocumentText = @「這是一個圖像:」'。你有什麼? – Noseratio

+0

CustomHtmlDoc = @」 <體背景= \ 「{0} \」; oncontextmenu = '返回false;'>




「+」ErrorMessage「+」

請確認儀表板配置的配置URL


「;當您提到「c:\ users \ ..... \ pic.png」時,設置絕對URL路徑時,它顯示正確。但是在部署的服務器中,不會顯示背景 – Darey

+0

您應該編輯了您的問題(不是註釋)以顯示代碼。無論如何,部署時絕對URL是什麼?它可以到達嗎? – Noseratio

回答

0

Windows窗體中的DocumentText實現沒有實現IMoniker,並且加載的文檔的基地址約爲:blank,因此您的頁面無法找到背景圖像。

您可以使用基本元素來指定相對URL的基本位置,或實現URL名稱。在http://www.codeproject.com/KB/miscctrl/csEXWB.aspx上有一個實現URL名稱的示例。在頁面上搜索LoadHtmlIntoBrowser(string html,string sBaseUrl)。

相關問題