Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to Load an HTML Page From Resources File?

How to Load an HTML Page From Resources File?

Scheduled Pinned Locked Moved Visual Basic
csharphtmlvisual-studiohelptutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saul Johnson
    wrote on last edited by
    #1

    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?

    L B K 3 Replies Last reply
    0
    • S Saul Johnson

      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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • L Lost User

        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.

        S Offline
        S Offline
        Saul Johnson
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • S Saul Johnson

          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?

          B Offline
          B Offline
          BDEz Member 3919223
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • S Saul Johnson

            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?

            K Offline
            K Offline
            Kenny McKee
            wrote on last edited by
            #5

            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...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups