How to Load an HTML Page From Resources File?
-
I've Searched for hours and still can't find the answer: How would you load an HTML Page from the resources file into a VS.NET WebBrowser Control using VB? It's an essential part of my application and I'm quite new to VB. Can anybody Help?
-
I've Searched for hours and still can't find the answer: How would you load an HTML Page from the resources file into a VS.NET WebBrowser Control using VB? It's an essential part of my application and I'm quite new to VB. Can anybody Help?
You can do:
WebBrowser1.DocumentText = My.Resources.HTMLFile
Where
HTMLFile
is the name of the HTML page you added to the Resources. Alternatively, you could write out the text of the HTML file and then navigate to it:My.Computer.FileSystem.WriteAllText("c:\file.html", My.Resources.HTMLFile, False)
WebBrowser1.Navigate("c:\file.html")I don't know of a way just to load the HTML file in the webbrowser control straight from the resources but that may be due to ignorance on my part.
-
You can do:
WebBrowser1.DocumentText = My.Resources.HTMLFile
Where
HTMLFile
is the name of the HTML page you added to the Resources. Alternatively, you could write out the text of the HTML file and then navigate to it:My.Computer.FileSystem.WriteAllText("c:\file.html", My.Resources.HTMLFile, False)
WebBrowser1.Navigate("c:\file.html")I don't know of a way just to load the HTML file in the webbrowser control straight from the resources but that may be due to ignorance on my part.
Thank you for your response. However I'm still having a little trouble. Apparently My HTML Page is not a member of My.Resources. Everything else is appearing in the intellisense panel apart from my web page and style sheet. Has Anybody got any idea why this might be?
-
I've Searched for hours and still can't find the answer: How would you load an HTML Page from the resources file into a VS.NET WebBrowser Control using VB? It's an essential part of my application and I'm quite new to VB. Can anybody Help?
I had problems with adding a resource once for an HTML file. I ended up booting it to the curb and writing my own HTML structure internal. Below is a quick HTML entry you can stream towards your WebBrowser object and it will work just fine. It builds a basic web page with a table and has simple Java script support VIA a text box entry. I also disabled any right click to view source function with the entry in the body section oncontextmenu=return false; Give it a try you may find this easier to deal with. ========================================================================= Dim tik As String = """" TextBox.Text = "Add some internal Java Script stuff here if you want for a pop up window or what not" WebBrowser1.DocumentText = "<%@ Page Language=" & tik & "VB" & tik & "%>" & ControlChars.NewLine & "<html><head><meta http-equiv=" & tik & "content-type" & tik & " content=" & tik & "text/html" & tik & ">" & ControlChars.NewLine & "" & _ "<script language=" & tik & "JavaScript" & tik & ">" & ControlChars.NewLine & "" & _ "<!-- hide" & ControlChars.NewLine & "" & _ "" & TextBox.Text & "" & _ "// -->" & ControlChars.NewLine & "" & _ "</script>" & ControlChars.NewLine & "" & _ "</head>" & ControlChars.NewLine & "<body topmargin=" & tik & "0" & tik & " marginwidth=" & tik & "0" & tik & " marginheight=" & tik & "0" & tik & " bgcolor=" & tik & "#FFFFFF" & tik & " text=" & tik & "#000000" & tik & " link=" & tik & "#000000" & tik & " vlink=" & tik & "#000000" & tik & " alink=" & tik & "#000000" & tik & " oncontextmenu=" & tik & "return false;" & tik & ">" & _ "<font size=" & tik & "2" & tik & " face=" & tik & "Arial, Helvetica, sans-serif" & tik & " color=" & tik & "#000000" & tik & "><table border=" & tik & "0" & tik & " width=" & tik & "610" & tik & " cellpadding=" & tik & "0" & tik & " cellspacing=" & tik & "0" & tik & " bgcolor=" & tik & "#FFFFFF" & tik & ">" & _ "<tr><td><font size=" & tik & "2" & tik & ">•<a href=" & tik & " http://www.codeproject.com" & t
-
I've Searched for hours and still can't find the answer: How would you load an HTML Page from the resources file into a VS.NET WebBrowser Control using VB? It's an essential part of my application and I'm quite new to VB. Can anybody Help?
why not save the file as a .txt file and add it to your resources, then save it as an .html file when you need it? ( or keep it a .txt file the whole time? )
How many bytes of text have I typed in my lifetime??? Man, I wish I kept track...