CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    26

    Saving HTML file to MemoryStream

    Hi,

    I currently save updated data to a text file formatted in HTML using StreamWriter. The file is named PP.Html. I use the Web Browser control to load PP.Html and display the updated information. Is there away in VB.Net to save the file to a MemoryStream and Load it with the Web Browser control? If so, please provide an example. I've searched but only find examples on saving images to MemoryStreams.

    Any help is appreciated.....

  2. #2
    Join Date
    Jun 2003
    Location
    Malaysia (P.J)
    Posts
    410

    Re: Saving HTML file to MemoryStream

    in ur form load:
    AxWebBrowser1.Navigate2("about:blank")

    in the event of AxWebBrowser1_DocumentComplete...
    WriteWebPage()


    write a sub as following:
    Private Sub WriteWebPage()
    Dim fStrValuePassed As String
    Dim myDoc As HTMLDocument
    myDoc = New HTMLDocumentClass
    myDoc = DirectCast(AxWebBrowser1.Document, HTMLDocumentClass)
    myDoc.body.innerHTML = fStrValuePassed
    'fStrValuePassed is the html code....

    End Sub

    And very important!!! import the reference microsoft.mhtml from the .net tab....
    Back after a long hibernation.

  3. #3
    Join Date
    Jul 2004
    Posts
    26

    Re: Saving HTML file to MemoryStream

    Hi,

    Thanks for the help. It works great, no need to save to file, however is it because i'm inserting into the body that I loose the spacing when I view the page in the browser control.

    This is a bit of what I created using stringbuilder.

    <html>
    <head>
    </script>
    <style type='text/css'>
    <!--
    body { font-family: PLHIRL+PaddockExt600700,Arial, Helvetica, Verdana, sans-serif; font-size: 9px; color: #000000; background-color: #FFFFFF}
    .pos { position: absolute; z-index: 0; left: 0px; top: 0px;}
    -->
    </style>
    </head>
    <body id='6' onload='' >
    <nobr>
    <div class='pos' id='_2:25' style=' top:25;left:2'><b><i><span id='_10' style='font-size:12px'><font color ='#000000'><span style='letter-spacing:-0.38 px'>Past</span> <span style='letter-spacing:-0.78 px'>Performances</span></i></b></div>
    <div class='pos' id='_358:25' style=' top:25;left:358'><b><i><span id='_7' style='font-size:12px'><span style='letter-spacing:-1.30 px'></span> <span style='letter-spacing:-0.52 px'>&nbsp; &nbsp;04/16/2005</span></span></i></b></div>
    'More lines here
    '
    '
    '
    </nobr></body>
    </html>

    The fonts are correct, just the positions of the text is lost...

    Again thanks for your support..

  4. #4
    Join Date
    Jun 2003
    Location
    Malaysia (P.J)
    Posts
    410

    Re: Saving HTML file to MemoryStream

    I'm not quite sure abt ur question...

    Assuming that i got ur question right...,
    Try not to use too many span tags unless if it's really required.

    If ur using frontpage tool to do this formatting... span tags r repeatedly created when u make too many changes. Redo the formatting in frontpage or any other tool ur using.

    I don't think there's any limitation in the IE control coz I hv been doing many of these type apps b4.
    Back after a long hibernation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured