Loading HTML into WebBrowser control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Boardman

    #1

    Loading HTML into WebBrowser control

    Can anyone tell me how I can write HTML to a WebBrowser control in
    Visual Basic 6? I want to display HTML in the browser that is generated
    from within my VB program (as opposed to loading it from a file or URL).
    Is this possible?

    Jason
  • Martin

    #2
    Re: Loading HTML into WebBrowser control

    In the url you can enter "about:<html>al l your html-content here</html>"

    "Jason Boardman" <jason12_@_icx. net> wrote in message
    news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...[color=blue]
    > Can anyone tell me how I can write HTML to a WebBrowser control in Visual
    > Basic 6? I want to display HTML in the browser that is generated from
    > within my VB program (as opposed to loading it from a file or URL).
    > Is this possible?
    >
    > Jason[/color]


    Comment

    • Jason Boardman

      #3
      Re: Loading HTML into WebBrowser control

      thanks martin,

      but i would imagine there's a limit to the length of text doing it that
      way. i want to write output to the WebBrowser control to display whole
      manual pages, etc that are stored in an ODBC database. do you know of
      any other way to accomplish this?

      jason

      Martin wrote:[color=blue]
      > In the url you can enter "about:<html>al l your html-content here</html>"
      >
      > "Jason Boardman" <jason12_@_icx. net> wrote in message
      > news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...
      >[color=green]
      >>Can anyone tell me how I can write HTML to a WebBrowser control in Visual
      >>Basic 6? I want to display HTML in the browser that is generated from
      >>within my VB program (as opposed to loading it from a file or URL).
      >>Is this possible?
      >>
      >>Jason[/color]
      >
      >
      >[/color]

      Comment

      • Martin

        #4
        Re: Loading HTML into WebBrowser control

        No, I don't. Maybe you can write the HTML to a temporary file, or you can
        use a richtextbox instead of the browser?

        "Jason Boardman" <jason12_@_icx. net> wrote in message
        news:X5Csf.5613 0$aS5.23191@big news4.bellsouth .net...[color=blue]
        > thanks martin,
        >
        > but i would imagine there's a limit to the length of text doing it that
        > way. i want to write output to the WebBrowser control to display whole
        > manual pages, etc that are stored in an ODBC database. do you know of
        > any other way to accomplish this?
        >
        > jason
        >
        > Martin wrote:[color=green]
        >> In the url you can enter "about:<html>al l your html-content here</html>"
        >>
        >> "Jason Boardman" <jason12_@_icx. net> wrote in message
        >> news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...
        >>[color=darkred]
        >>>Can anyone tell me how I can write HTML to a WebBrowser control in Visual
        >>>Basic 6? I want to display HTML in the browser that is generated from
        >>>within my VB program (as opposed to loading it from a file or URL).
        >>>Is this possible?
        >>>
        >>>Jason[/color]
        >>
        >>[/color][/color]

        Comment

        • Steve Gerrard

          #5
          Re: Loading HTML into WebBrowser control


          "Jason Boardman" <jason12_@_icx. net> wrote in message
          news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...[color=blue]
          > Can anyone tell me how I can write HTML to a WebBrowser control in Visual
          > Basic 6? I want to display HTML in the browser that is generated from within
          > my VB program (as opposed to loading it from a file or URL).
          > Is this possible?
          >[/color]

          That is pretty much a description of what an ASP web server does (that's Active
          Server Pages). Unless you plan to write your own version of ASP or its
          equivalent, I don't think you can easily do it in VB.


          Comment

          • Dikkie Dik

            #6
            Re: Loading HTML into WebBrowser control

            Jason Boardman wrote:[color=blue]
            > Can anyone tell me how I can write HTML to a WebBrowser control in
            > Visual Basic 6? I want to display HTML in the browser that is generated
            > from within my VB program (as opposed to loading it from a file or URL).
            > Is this possible?
            >
            > Jason[/color]
            Is it possible to do both from the start? I mean, if your HTML is
            generated, you could also generate the rendering into a picturebox, a
            rich text control or whatever.

            Comment

            • George Bashore

              #7
              Re: Loading HTML into WebBrowser control

              Jason try this.
              1 textbox multiline= True
              1 WebBrowser
              2 command buttons
              this code will get you started
              Now you can add tags for centering, fonts, images and whatever.
              save before viewing in browser if you make changes to HTML code



              Option Explicit
              Private Sub Command1_Click( )
              'save textbox code to harddrive
              'to view in WebBrowser1
              Dim FF
              FF = FreeFile
              Open "c:\test.ht ml" For Output As #FF
              Print #FF, Text1.Text
              Close #FF
              End Sub

              Private Sub Command2_Click( )
              WebBrowser1.Nav igate "c:\test.ht ml"
              End Sub

              Private Sub Form_Load()
              Text1.Text = "<html><head><t itle>New Page 1</title></head><body><p>H ello
              World</p></body></html>"
              Command1.Captio n = "Save"
              Command2.Captio n = "Open in Browser"
              End Sub



              "Jason Boardman" <jason12_@_icx. net> wrote in message
              news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...[color=blue]
              > Can anyone tell me how I can write HTML to a WebBrowser control in Visual
              > Basic 6? I want to display HTML in the browser that is generated from
              > within my VB program (as opposed to loading it from a file or URL).
              > Is this possible?
              >
              > Jason[/color]


              Comment

              • Jason Boardman

                #8
                Re: Loading HTML into WebBrowser control

                Thanks for your reply - actually i'm not really trying to do anything
                like ASP, i'm just trying to view a bunch of HTML stored in a database
                in a browser control without having to have it served up by a webserver.
                I've found I can use browser.documen t.write to write directly to the
                browser control so all is well.

                Thanks,
                Jason

                Steve Gerrard wrote:[color=blue]
                > "Jason Boardman" <jason12_@_icx. net> wrote in message
                > news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...
                >[color=green]
                >>Can anyone tell me how I can write HTML to a WebBrowser control in Visual
                >>Basic 6? I want to display HTML in the browser that is generated from within
                >>my VB program (as opposed to loading it from a file or URL).
                >>Is this possible?
                >>[/color]
                >
                >
                > That is pretty much a description of what an ASP web server does (that's Active
                > Server Pages). Unless you plan to write your own version of ASP or its
                > equivalent, I don't think you can easily do it in VB.
                >
                >[/color]

                Comment

                • Jason Boardman

                  #9
                  Re: Loading HTML into WebBrowser control

                  Well the HTML isn't really generated, it's already stored in an ODBC
                  database that my VB program is connected to, so i've decided to load it
                  into a standard recordset then use browsername.doc ument.write to just
                  write directly to the control.

                  Thanks,
                  Jason

                  Dikkie Dik wrote:[color=blue]
                  > Jason Boardman wrote:
                  >[color=green]
                  >> Can anyone tell me how I can write HTML to a WebBrowser control in
                  >> Visual Basic 6? I want to display HTML in the browser that is
                  >> generated from within my VB program (as opposed to loading it from a
                  >> file or URL).
                  >> Is this possible?
                  >>
                  >> Jason[/color]
                  >
                  > Is it possible to do both from the start? I mean, if your HTML is
                  > generated, you could also generate the rendering into a picturebox, a
                  > rich text control or whatever.[/color]

                  Comment

                  • Jason Boardman

                    #10
                    Re: Loading HTML into WebBrowser control

                    Thanks for the reply George, but I was looking for a way to do it all
                    internally, circumventing the need to write to an external file, then
                    read it back in. I think I have it figured out now (see above posts)

                    Thanks!
                    Jason

                    George Bashore wrote:[color=blue]
                    > Jason try this.
                    > 1 textbox multiline= True
                    > 1 WebBrowser
                    > 2 command buttons
                    > this code will get you started
                    > Now you can add tags for centering, fonts, images and whatever.
                    > save before viewing in browser if you make changes to HTML code
                    >
                    >
                    >
                    > Option Explicit
                    > Private Sub Command1_Click( )
                    > 'save textbox code to harddrive
                    > 'to view in WebBrowser1
                    > Dim FF
                    > FF = FreeFile
                    > Open "c:\test.ht ml" For Output As #FF
                    > Print #FF, Text1.Text
                    > Close #FF
                    > End Sub
                    >
                    > Private Sub Command2_Click( )
                    > WebBrowser1.Nav igate "c:\test.ht ml"
                    > End Sub
                    >
                    > Private Sub Form_Load()
                    > Text1.Text = "<html><head><t itle>New Page 1</title></head><body><p>H ello
                    > World</p></body></html>"
                    > Command1.Captio n = "Save"
                    > Command2.Captio n = "Open in Browser"
                    > End Sub
                    >
                    >
                    >
                    > "Jason Boardman" <jason12_@_icx. net> wrote in message
                    > news:qUAsf.1071 $Nr6.246@bignew s5.bellsouth.ne t...
                    >[color=green]
                    >>Can anyone tell me how I can write HTML to a WebBrowser control in Visual
                    >>Basic 6? I want to display HTML in the browser that is generated from
                    >>within my VB program (as opposed to loading it from a file or URL).
                    >>Is this possible?
                    >>
                    >>Jason[/color]
                    >
                    >
                    >[/color]

                    Comment

                    Working...